INNER CODE UNIT · TypeScript

createCipher

paulmillr/noble-ciphers · src/_arx.ts:238

export function createCipher(core: TArg<CipherCoreFn>, opts: TArg<CipherOpts>): TRet<XorStream> {
  const { allowShortKeys, extendNonceFn, counterLength, counterRight, rounds } = checkOpts(
    { allowShortKeys: false, counterLength: 8, counterRight: false, rounds: 20 },
    opts
  );
  if (typeof core !== 'function') throw new Error('core must be a function');
  anumber(counterLength);
  anumber(rounds);
  abool(counterRight);
  abool(allowShortKeys);
  return (
    key: TArg<Uint8Array>,
    nonce: TArg<Uint8Array>,
    data: TArg<Uint8Array>,
    output?: TArg<Uint8Array>,
    counter = 0
  ): TRet<Uint8Array> => {
    abytes(key, undefined, 'key');

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…