2022-09-15 22:58:45 -04:00
|
|
|
import { keccak256 } from "../crypto/index.js";
|
2022-09-05 16:57:11 -04:00
|
|
|
import { toUtf8Bytes } from "../utils/index.js";
|
2022-12-09 18:24:58 -05:00
|
|
|
/**
|
|
|
|
* A simple hashing function which operates on UTF-8 strings to
|
2023-04-19 17:30:37 +09:00
|
|
|
* compute an 32-byte identifier.
|
2022-12-09 18:24:58 -05:00
|
|
|
*
|
|
|
|
* This simply computes the [UTF-8 bytes](toUtf8Bytes) and computes
|
|
|
|
* the [[keccak256]].
|
|
|
|
*
|
|
|
|
* @example:
|
|
|
|
* id("hello world")
|
|
|
|
* //_result:
|
|
|
|
*/
|
2022-09-05 16:57:11 -04:00
|
|
|
export function id(value) {
|
|
|
|
return keccak256(toUtf8Bytes(value));
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=id.js.map
|