Nodejs Utililty Methods Base64 Decode

List of utility methods to do Base64 Decode

Description

The list of methods to do Base64 Decode are organized into topic(s).

Method

fromBase64()
String.prototype.fromBase64 = function () {
    var converter = new Buffer(this.toString(), 'base64');
    return converter.toString('utf8');
fromBase64()
String.prototype.fromBase64 = function () {
  var str = this;
  var output = str.replace('-', '+').replace('_', '/');
  switch (output.length % 4) {
    case 0:
      break;
    case 2:
      output += '==';
      break;
...
fromBase64()
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)
...
fromBase64()
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)
          )
        )
...
fromBase64()
String.prototype.fromBase64 = function() {
  var 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) {
...