ripemd160.js 1.1 KB

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