pbkdf2.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * A **Password-Based Key-Derivation Function** is designed to create
  3. * a sequence of bytes suitible as a **key** from a human-rememberable
  4. * password.
  5. *
  6. * @_subsection: api/crypto:Passwords [about-pbkdf]
  7. */
  8. import type { BytesLike } from "../utils/index.js";
  9. /**
  10. * Return the [[link-pbkdf2]] for %%keylen%% bytes for %%password%% using
  11. * the %%salt%% and using %%iterations%% of %%algo%%.
  12. *
  13. * This PBKDF is outdated and should not be used in new projects, but is
  14. * required to decrypt older files.
  15. *
  16. * @example:
  17. * // The password must be converted to bytes, and it is generally
  18. * // best practices to ensure the string has been normalized. Many
  19. * // formats explicitly indicate the normalization form to use.
  20. * password = "hello"
  21. * passwordBytes = toUtf8Bytes(password, "NFKC")
  22. *
  23. * salt = id("some-salt")
  24. *
  25. * // Compute the PBKDF2
  26. * pbkdf2(passwordBytes, salt, 1024, 16, "sha256")
  27. * //_result:
  28. */
  29. export declare function pbkdf2(_password: BytesLike, _salt: BytesLike, iterations: number, keylen: number, algo: "sha256" | "sha512"): string;
  30. export declare namespace pbkdf2 {
  31. var _: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike;
  32. var lock: () => void;
  33. var register: (func: (password: Uint8Array, salt: Uint8Array, iterations: number, keylen: number, algo: "sha256" | "sha512") => BytesLike) => void;
  34. }
  35. //# sourceMappingURL=pbkdf2.d.ts.map