ripemd160.js 959 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ripemd160 as noble_ripemd160 } from "@noble/hashes/ripemd160";
  2. import { getBytes, hexlify } from "../utils/index.js";
  3. let locked = false;
  4. const _ripemd160 = function (data) {
  5. return noble_ripemd160(data);
  6. };
  7. let __ripemd160 = _ripemd160;
  8. /**
  9. * Compute the cryptographic RIPEMD-160 hash of %%data%%.
  10. *
  11. * @_docloc: api/crypto:Hash Functions
  12. * @returns DataHexstring
  13. *
  14. * @example:
  15. * ripemd160("0x")
  16. * //_result:
  17. *
  18. * ripemd160("0x1337")
  19. * //_result:
  20. *
  21. * ripemd160(new Uint8Array([ 0x13, 0x37 ]))
  22. * //_result:
  23. *
  24. */
  25. export function ripemd160(_data) {
  26. const data = getBytes(_data, "data");
  27. return hexlify(__ripemd160(data));
  28. }
  29. ripemd160._ = _ripemd160;
  30. ripemd160.lock = function () { locked = true; };
  31. ripemd160.register = function (func) {
  32. if (locked) {
  33. throw new TypeError("ripemd160 is locked");
  34. }
  35. __ripemd160 = func;
  36. };
  37. Object.freeze(ripemd160);
  38. //# sourceMappingURL=ripemd160.js.map