Skip to content

Commit

Permalink
Merge branch 'master' into fix-keysend
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis authored Sep 26, 2023
2 parents 23ddf61 + 7551098 commit 6487b07
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions utils/Base64Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ class Base64Utils {
Buffer.from(input).toString('base64');
decodeBase64ToString = (input = '') =>
Buffer.from(input, 'base64').toString('utf8');
btoa = (input = '') => {
const str = input;
let output = '';

for (
let block = 0, charCode, i = 0, map = chars;

Check failure on line 11 in utils/Base64Utils.ts

View workflow job for this annotation

GitHub Actions / lint

'chars' is not defined
str.charAt(i | 0) || ((map = '='), i % 1);
output += map.charAt(63 & (block >> (8 - (i % 1) * 8)))
) {
charCode = str.charCodeAt((i += 3 / 4));

if (charCode > 0xff) {
throw new Error(
"'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."
);
}

block = (block << 8) | charCode;
}

return output;
};

hexToBase64 = (str = '') => Buffer.from(str, 'hex').toString('base64');

Expand Down

0 comments on commit 6487b07

Please sign in to comment.