How to use the libsodium-wrappers.to_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 stringifyValue(v){
  var tv = typeof v;
  if (tv == 'string') return v;
  else if (tv == 'number' || tv == 'boolean') return v.toString();
  else if (v instanceof Date) return v.getTime().toString();
  else if (v instanceof Uint8Array) return libsodium.to_base64(v);
  else if (tv == 'object') return JSON.stringify(v);
  else {
    console.log(v);
    console.log(JSON.stringify(v));
    throw new TypeError('Cannot stringifyValue() of type ' + tv);
  }
}
github whs / ipfs-encrypted-share / src / lib / browserencrypt.js View on Github external
return promise.then((pieces) => {
			let metadata = {
				header: sodium.to_base64(header, sodium.base64_variants.ORIGINAL_NO_PADDING),
				encryptedMetadata: sodium.to_base64(metadataEncrypted, sodium.base64_variants.ORIGINAL_NO_PADDING),
			};

			return {
				pieces,
				metadata,
				key: sodium.to_base64(key, sodium.base64_variants.URLSAFE_NO_PADDING),
			};
		});
	});
github TankerHQ / sdk-js / packages / crypto / src / utils.js View on Github external
export function toBase64(bytes: Uint8Array): b64string {
  if (!(bytes instanceof Uint8Array))
    throw new TypeError('"bytes" is not a Uint8Array');

  return sodium.to_base64(bytes);
}