bcrypt-b64.js
function decode(str) {
  let off = 0;
  let olen = 0;
  const slen = str.length;
  const stra = [];
  const len = str.length;

  while (off < slen - 1 && olen < len) {
    let code = str.charCodeAt(off++);
    const c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    code = str.charCodeAt(off++);
    const c2 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    if (c1 === -1 || c2 === -1) break;
    let o = (c1 << 2) >>> 0;
    o |= (c2 & 0x30) >> 4;
    stra.push(String.fromCharCode(o));
    if (++olen >= len || off >= slen) break;
    code = str.charCodeAt(off++);
    const c3 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    if (c3 === -1) break;
    o = ((c2 & 0x0f) << 4) >>> 0;
    o |= (c3 & 0x3c) >> 2;
    stra.push(String.fromCharCode(o));
    if (++olen >= len || off >= slen) break;
    code = str.charCodeAt(off++);
    const c4 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    o = ((c3 & 0x03) << 6) >>> 0;
    o |= c4;
    stra.push(String.fromCharCode(o));
    ++olen;
  }
  const buffa = [];
  for (off = 0; off < olen; off++) buffa.push(stra[off].charCodeAt(0));
  return Buffer.from(buffa);
}
function decode(str) {
  let off = 0;
  let olen = 0;
  const slen = str.length;
  const stra = [];
  const len = str.length;

  while (off < slen - 1 && olen < len) {
    let code = str.charCodeAt(off++);
    const c1 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    code = str.charCodeAt(off++);
    const c2 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    if (c1 === -1 || c2 === -1) break;
    let o = (c1 << 2) >>> 0;
    o |= (c2 & 0x30) >> 4;
    stra.push(String.fromCharCode(o));
    if (++olen >= len || off >= slen) break;
    code = str.charCodeAt(off++);
    const c3 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    if (c3 === -1) break;
    o = ((c2 & 0x0f) << 4) >>> 0;
    o |= (c3 & 0x3c) >> 2;
    stra.push(String.fromCharCode(o));
    if (++olen >= len || off >= slen) break;
    code = str.charCodeAt(off++);
    const c4 = code < BASE64_INDEX.length ? BASE64_INDEX[code] : -1;
    o = ((c3 & 0x03) << 6) >>> 0;
    o |= c4;
    stra.push(String.fromCharCode(o));
    ++olen;
  }
  const buffa = [];
  for (off = 0; off < olen; off++) buffa.push(stra[off].charCodeAt(0));
  return Buffer.from(buffa);
}
function decode ( str ) { let off = 0 ; let olen = 0 ; const slen = str . length ; const stra = [ ] ; const len = str . length ; while ( off < slen - 1 && olen < len ) { let code = str . charCodeAt ( off ++ ) ; const c1 = code < BASE64_INDEX . length ? BASE64_INDEX [ code ] : - 1 ; code = str . charCodeAt ( off ++ ) ; const c2 = code < BASE64_INDEX . length ? BASE64_INDEX [ code ] : - 1 ; if ( c1 === - 1 || c2 === - 1 ) break ; let o = ( c1 << 2 ) >>> 0 ; o |= ( c2 & 0x30 ) >> 4 ; stra . push ( String . fromCharCode ( o ) ) ; if ( ++ olen >= len || off >= slen ) break ; code = str . charCodeAt ( off ++ ) ; const c3 = code < BASE64_INDEX . length ? BASE64_INDEX [ code ] : - 1 ; if ( c3 === - 1 ) break ; o = ( ( c2 & 0x0f ) << 4 ) >>> 0 ; o |= ( c3 & 0x3c ) >> 2 ; stra . push ( String . fromCharCode ( o ) ) ; if ( ++ olen >= len || off >= slen ) break ; code = str . charCodeAt ( off ++ ) ; const c4 = code < BASE64_INDEX . length ? BASE64_INDEX [ code ] : - 1 ; o = ( ( c3 & 0x03 ) << 6 ) >>> 0 ; o |= c4 ; stra . push ( String . fromCharCode ( o ) ) ; ++ olen ; } const buffa = [ ] ; for ( off = 0 ; off < olen ; off ++ ) buffa . push ( stra [ off ] . charCodeAt ( 0 ) ) ; return Buffer . from ( buffa ) ; }
Decodes a base64 encoded string using the bcrypt's base64 dictionary.
@param {string} str String to decode.
@returns {Buffer} The string decoded as a Buffer.
@inner
Decodes a base64 encoded string using the bcrypt s base64 dictionary .