13 lines
347 B
JavaScript
13 lines
347 B
JavaScript
"use strict";
|
|
|
|
const b64Alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
|
|
|
function atob(str) {
|
|
for (const ch of str)
|
|
if (!b64Alphabet.includes(ch))
|
|
throw new Error(`Invalid character '${ch}' in base64 String`);
|
|
return Buffer.from(str, 'base64').toString('binary');
|
|
}
|
|
|
|
module.exports = atob.atob = atob;
|