2019-08-21 08:53:47 +03:00
|
|
|
_title: Hashing
|
|
|
|
|
|
|
|
_section: Hashing Algorithms
|
|
|
|
|
|
|
|
Explain what hash functions are?
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: Cryptographic Hashing
|
|
|
|
|
|
|
|
The [Cryptographic Hash Functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
|
|
|
|
are a specific family of hash functions.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.keccak256(aBytesLike) => string<[[datahexstring]]<32>> @<utils-keccak256> @SRC<keccak256>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) digest //aBytesLike//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.ripemd160(aBytesLike) => string<[[datahexstring]]<20>> @<utils-ripemd160> @SRC<sha2>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [RIPEMD-160](https://en.m.wikipedia.org/wiki/RIPEMD) digest of //aBytesLike//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.sha256(aBytesLike) => string<[[datahexstring]]<32>> @<utils-sha256> @SRC<sha2:function.sha256>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.sha512(aBytesLike) => string<[[datahexstring]]<64>> @<utils-sha512> @SRC<sha2:function.sha512>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.computeHmac(algorithm, key, data) => string<[[datahexstring]]> @<utils-computehmac> @SRC<sha2>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [HMAC](https://en.wikipedia.org/wiki/HMAC) of //data// with //key//
|
|
|
|
using the [Algorithm](supported-algorithm) //algorithm//.
|
|
|
|
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_heading: HMAC Supported Algorithms @<supported-algorithm> @SRC<sha2:enum.SupportedAlgorithms>
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
_property: utils.SupportedAlgorithms.sha256 => string
|
2019-08-21 08:53:47 +03:00
|
|
|
Use the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
_property: utils.SupportedAlgorithms.sha512 => string
|
2019-08-21 08:53:47 +03:00
|
|
|
Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: Common Hashing Helpers
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.hashMessage(message) => string<[[datahexstring]]<32>> @<utils-hashmessage> @SRC<hash>
|
2019-08-21 08:53:47 +03:00
|
|
|
Computes the Ethereum message digest of //message//. Ethereum messages are
|
|
|
|
converted to UTF-8 bytes and prefixed with ``\x19Ethereum Signed Message:``
|
|
|
|
and the length of //message//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.id(text) => string<[[datahexstring]]<32>> @<utils-id> @SRC<hash>
|
2019-08-21 08:53:47 +03:00
|
|
|
The Ethereum Identity function computs the keccak256 hash of the //text// bytes.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.namehash(name) => string<[[datahexstring]]<32>> @<utils-namehash> @SRC<hash>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of //name//.
|
|
|
|
|
|
|
|
|
|
|
|
_subsection: Solidity Hashing Algorithms
|
|
|
|
|
|
|
|
When using the Solidity ``abi.packEncoded(...)`` function, a non-standard
|
|
|
|
//tightly packed// version of encoding is used. These functions implement
|
|
|
|
the tightly packing algorithm.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.solidityPack(arrayOfTypes, arrayOfValues) => string<[[datahexstring]]> @<utils-soliditypack> @SRC<solidity:pack>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the non-standard encoded //arrayOfValues// packed according to
|
|
|
|
their respecive type in //arrayOfTypes//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.solidityKeccak256(arrayOfTypes, arrayOfValues) => string<[[datahexstring]]<32>> @<utils-soliditykeccak256> @SRC<solidity:keccak256>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the KECCAK256 of the non-standard encoded //arrayOfValues// packed
|
|
|
|
according to their respective type in //arrayOfTypes//.
|
|
|
|
|
2020-01-10 09:01:00 +03:00
|
|
|
_property: utils.soliditySha256(arrayOfTypes, arrayOfValues) => string<[[datahexstring]]<32>> @<utils-soliditysha256> @SRC<solidity:sha256>
|
2019-08-21 08:53:47 +03:00
|
|
|
Returns the SHA2-256 of the non-standard encoded //arrayOfValues// packed
|
|
|
|
according to their respective type in //arrayOfTypes//.
|
|
|
|
|
|
|
|
|