How to use the libsodium-wrappers-sumo.from_base64 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-webapp / src / script / util / util.ts View on Github external
export const base64ToArray = async (base64: string): Promise => {
  await sodium.ready;
  return sodium.from_base64(stripDataUri(base64), sodium.base64_variants.ORIGINAL);
};
github kryptco / kr-u2f / src / crypto.ts View on Github external
export async function from_base64_url_nopad(s: string) {
    await sodium.ready;
    return sodium.from_base64(s, sodium.base64_variants.URLSAFE_NO_PADDING);
}
github TankerHQ / quickstart-examples / server / src / auth.js View on Github external
const parsePasswordResetToken = (b64token) => {
  const buf = sodium.from_base64(b64token);
  const string = sodium.to_string(buf);
  return JSON.parse(string);
};
github kryptco / kr-u2f / src / crypto.ts View on Github external
export async function from_base64_url(s: string) {
    await sodium.ready;
    return sodium.from_base64(s, sodium.base64_variants.URLSAFE);
}