Here you can find the source of fromBase64()
String.prototype.fromBase64 = function() { var m = {};/*www . j a v a 2 s. c o m*/ var toChar = String.fromCharCode; code.forEach(function(value, index) { m[value] = index; }); var decoded = []; var a, b, c, d; for (var i = 0, len = this.length; i < len; i = i + 4) { a = this.charAt(i); b = this.charAt(i + 1); decoded.push(toChar(m[a] << 2 | m[b] >> 4)); c = this.charAt(i + 2); if ( c !== '=' ) { decoded.push(toChar((m[b] & 15) << 4 | m[c] >> 2)); d = this.charAt(i + 3); if ( d !== '=' ) { decoded.push(toChar((m[c] & 3) << 6 | m[d])); } } } return decoded.join(''); }
String.prototype.fromBase64 = function () { var converter = new Buffer(this.toString(), 'base64'); return converter.toString('utf8');
String.prototype.fromBase64 = function () { var str = this; var output = str.replace('-', '+').replace('_', '/'); switch (output.length % 4) { case 0: break; case 2: output += '=='; break; ...
const CODES = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' String.prototype.fromBase64 = function() { let out = '' for (let i = 0, length = this.length; i < length; i += 4) { let [a, b, c, d] = [...this.slice(i, i + 4)].map(c => CODES.indexOf(c)) bits = a << 18 | b << 12 | c << 6 | d out += String.fromCharCode(bits >> 16) if (c !== 64) out += String.fromCharCode(bits >> 8 & 0xFF) if (d !== 64) out += String.fromCharCode(bits & 0xFF) ...
String.prototype.fromBase64 = function(){ var ordToN = function(ord){ return ord=="=".charCodeAt(0) ? 0 : ( ord=="/".charCodeAt(0) ? 63 : ( ord=="+".charCodeAt(0) ? 62 : ( ord>="0".charCodeAt(0) && ord<="9".charCodeAt(0) ? ord-"0".charCodeAt(0)+52 : ( ord>="a".charCodeAt(0) && ord<="z".charCodeAt(0) ? ord-"a".charCodeAt(0)+26 : ord-"A".charCodeAt(0) ) ) ...