Path: blob/main/extensions/microsoft-authentication/src/browser/buffer.ts
3321 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45export function base64Encode(text: string): string {6return btoa(text);7}89export function base64Decode(text: string): string {10// modification of https://stackoverflow.com/a/3855230211const replacedCharacters = text.replace(/-/g, '+').replace(/_/g, '/');12const decodedText = decodeURIComponent(atob(replacedCharacters).split('').map(function (c) {13return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);14}).join(''));15return decodedText;16}171819