How to use the libsodium-wrappers.from_base64 function in libsodium-wrappers

To help you get started, we’ve selected a few libsodium-wrappers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LockateMe / Lawncipher / tests / indexmodel.js View on Github external
function destringifyValue(v, t){
  if (t == 'string') return v;
  else if (t == 'number') return parseFloat(v);
  else if (t == 'boolean'){
    v = v.toLowerCase();
    if (!(v == 'true' || v == 'false')) throw new RangeError('Invalid stringified boolean value: ' + v);
    return v == 'true' ? true : false;
  } else if (t == 'date'){
    return new Date(parseInt(v));
  } else if (t == 'buffer') return libsodium.from_base64(v);
  else if (t == 'object') return JSON.parse(v);
  else throw new TypeError('Unsupported type: ' + t);
}
github TankerHQ / sdk-js / packages / crypto / src / utils.js View on Github external
export function fromBase64(str: b64string): Uint8Array {
  if (typeof str !== 'string')
    throw new TypeError('"str" is not a string');

  return sodium.from_base64(str);
}
github sjudson / paseto.js / lib / utils.js View on Github external
function fromB64URLSafe(str) {
  if (!(typeof str === 'string')) { throw new TypeError('Can only decode string'); }
  return Buffer.from(sodium.from_base64(str, sodium.base64_variants.URLSAFE_NO_PADDING));
}
github whs / ipfs-encrypted-share / src / lib / browserdecrypt.js View on Github external
constructor(key) {
		this.key = sodium.from_base64(key, sodium.base64_variants.URLSAFE_NO_PADDING);
	}
github Picolab / pico-engine / packages / pico-engine-core / src / modules / indy.js View on Github external
function b64dec (input) {
  return sodium.from_base64(input, sodium.base64_variants.URLSAFE)
}