How to use the libsodium-wrappers-sumo.base64_variants function in libsodium-wrappers-sumo

To help you get started, we’ve selected a few libsodium-wrappers-sumo 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 wireapp / wire-web-packages / packages / proteus / spec / keys / PreKeyBundleSpec.ts View on Github external
it('should generate a serialised JSON format', async () => {
    const pre_key_id = 72;

    const [identity_key_pair, pre_key] = await Promise.all([
      Proteus.keys.IdentityKeyPair.new(),
      Proteus.keys.PreKey.new(pre_key_id),
    ]);
    const public_identity_key = identity_key_pair.public_key;
    const pre_key_bundle = Proteus.keys.PreKeyBundle.new(public_identity_key, pre_key);
    const serialised_pre_key_bundle_json = pre_key_bundle.serialised_json();

    expect(serialised_pre_key_bundle_json.id).toBe(pre_key_id);

    const serialised_array_buffer_view = sodium.from_base64(
      serialised_pre_key_bundle_json.key,
      sodium.base64_variants.ORIGINAL,
    );
    const serialised_array_buffer = serialised_array_buffer_view.buffer;
    const deserialised_pre_key_bundle = Proteus.keys.PreKeyBundle.deserialise(serialised_array_buffer);

    expect(deserialised_pre_key_bundle.public_key).toEqual(pre_key_bundle.public_key);
  });
});
github wireapp / wire-web-packages / packages / proteus / src / main / keys / PreKeyBundle.ts View on Github external
serialised_json(): SerialisedJSON {
    return {
      id: this.prekey_id,
      key: sodium.to_base64(new Uint8Array(this.serialise()), sodium.base64_variants.ORIGINAL),
    };
  }
github wireapp / wire-web-packages / packages / proteus / src / main / keys / PreKeyBundle.ts View on Github external
serialised_json(): SerialisedJSON {
    return {
      id: this.prekey_id,
      key: sodium.to_base64(new Uint8Array(this.serialise()), sodium.base64_variants.ORIGINAL),
    };
  }
github kryptco / kr-u2f / src / crypto.ts View on Github external
export async function to_base64_url_nopad(d: string | Uint8Array) {
    await sodium.ready;
    return sodium.to_base64(d, sodium.base64_variants.URLSAFE_NO_PADDING);
}
github auth0 / magic / magic.js View on Github external
return rand(sec).then((bytes) => {
    return done(null, sodium.to_base64(bytes, sodium.base64_variants.URLSAFE_NO_PADDING));
  }).catch((err) => { return done(err); })
}
github wireapp / wire-webapp / src / script / util / util.ts View on Github external
export const arrayToMd5Base64 = async (array: Uint8Array): Promise => {
  await sodium.ready;
  const md5Hash = JsMD5.arrayBuffer(array);
  return sodium.to_base64(new Uint8Array(md5Hash), sodium.base64_variants.ORIGINAL);
};