scrypt.d.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { type KDFInput } from './utils.ts';
  2. export type ScryptOpts = {
  3. N: number;
  4. r: number;
  5. p: number;
  6. dkLen?: number;
  7. asyncTick?: number;
  8. maxmem?: number;
  9. onProgress?: (progress: number) => void;
  10. };
  11. /**
  12. * Scrypt KDF from RFC 7914.
  13. * @param password - pass
  14. * @param salt - salt
  15. * @param opts - parameters
  16. * - `N` is cpu/mem work factor (power of 2 e.g. 2**18)
  17. * - `r` is block size (8 is common), fine-tunes sequential memory read size and performance
  18. * - `p` is parallelization factor (1 is common)
  19. * - `dkLen` is output key length in bytes e.g. 32.
  20. * - `asyncTick` - (default: 10) max time in ms for which async function can block execution
  21. * - `maxmem` - (default: `1024 ** 3 + 1024` aka 1GB+1KB). A limit that the app could use for scrypt
  22. * - `onProgress` - callback function that would be executed for progress report
  23. * @returns Derived key
  24. * @example
  25. * scrypt('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 });
  26. */
  27. export declare function scrypt(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Uint8Array;
  28. /**
  29. * Scrypt KDF from RFC 7914. Async version.
  30. * @example
  31. * await scryptAsync('password', 'salt', { N: 2**18, r: 8, p: 1, dkLen: 32 });
  32. */
  33. export declare function scryptAsync(password: KDFInput, salt: KDFInput, opts: ScryptOpts): Promise<Uint8Array>;
  34. //# sourceMappingURL=scrypt.d.ts.map