INNER CODE UNIT · TypeScript

cipherSame

paulmillr/noble-ciphers · benchmark/thirdparty/index.ts:28

const cipherSame = (fn) => ({ encrypt: fn, decrypt: fn });

let chainsafe_chacha_poly;

// Works for gcm only?
const nodeGCM = (name) => {
  return {
    encrypt: (buf, opts) => {
      const res = [];
      const c = createCipheriv(name, opts.key, opts.iv);
      if (opts.aad) c.setAAD(opts.aad);
      res.push(c.update(buf));
      res.push(c.final());
      res.push(c.getAuthTag());
      return concatBytes(...res.map((i) => Uint8Array.from(i)));
    },
    decrypt: (buf, opts) => {
      const ciphertext = buf.slice(0, -16);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…