id.js 460 B

1234567891011121314151617
  1. import { keccak256 } from "../crypto/index.js";
  2. import { toUtf8Bytes } from "../utils/index.js";
  3. /**
  4. * A simple hashing function which operates on UTF-8 strings to
  5. * compute an 32-byte identifier.
  6. *
  7. * This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes
  8. * the [[keccak256]].
  9. *
  10. * @example:
  11. * id("hello world")
  12. * //_result:
  13. */
  14. export function id(value) {
  15. return keccak256(toUtf8Bytes(value));
  16. }
  17. //# sourceMappingURL=id.js.map