pbkdf2.d.ts 981 B

1234567891011121314151617181920212223
  1. import { type CHash, type KDFInput } from './utils.ts';
  2. export type Pbkdf2Opt = {
  3. c: number;
  4. dkLen?: number;
  5. asyncTick?: number;
  6. };
  7. /**
  8. * PBKDF2-HMAC: RFC 2898 key derivation function
  9. * @param hash - hash function that would be used e.g. sha256
  10. * @param password - password from which a derived key is generated
  11. * @param salt - cryptographic salt
  12. * @param opts - {c, dkLen} where c is work factor and dkLen is output message size
  13. * @example
  14. * const key = pbkdf2(sha256, 'password', 'salt', { dkLen: 32, c: Math.pow(2, 18) });
  15. */
  16. export declare function pbkdf2(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Uint8Array;
  17. /**
  18. * PBKDF2-HMAC: RFC 2898 key derivation function. Async version.
  19. * @example
  20. * await pbkdf2Async(sha256, 'password', 'salt', { dkLen: 32, c: 500_000 });
  21. */
  22. export declare function pbkdf2Async(hash: CHash, password: KDFInput, salt: KDFInput, opts: Pbkdf2Opt): Promise<Uint8Array>;
  23. //# sourceMappingURL=pbkdf2.d.ts.map