Crate sp_core_hashing_proc_macro
source ·Expand description
Macros to calculate constant hash bytes result.
Macros from this crate does apply a specific hash function on input.
Input can be literal byte array as b"content"
or array of bytes
as [1, 2, 3]
.
Rust identifier can also be use, in this case we use their utf8 string
byte representation, for instance if the ident is MyStruct
, then
b"MyStruct"
will be hashed.
If multiple arguments comma separated are passed, they are concatenated
then hashed.
Examples:
assert_eq!(
sp_core_hashing_proc_macro::blake2b_256!(b"test"),
sp_core_hashing::blake2_256(b"test"),
);
assert_eq!(
sp_core_hashing_proc_macro::blake2b_256!([1u8]),
sp_core_hashing::blake2_256(&[1u8]),
);
assert_eq!(
sp_core_hashing_proc_macro::blake2b_256!([1, 2, 3]),
sp_core_hashing::blake2_256(&[1, 2, 3]),
);
assert_eq!(
sp_core_hashing_proc_macro::blake2b_256!(identifier),
sp_core_hashing::blake2_256(b"identifier"),
);
assert_eq!(
sp_core_hashing_proc_macro::blake2b_256!(identifier, b"/string"),
sp_core_hashing::blake2_256(b"identifier/string"),
);
Macros
Process a Blake2 64-bit hash of bytes parameter outputs a
[u8; 8]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a Blake2 256-bit hash of bytes parameter, outputs a
[u8; 32]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a Blake2 512-bit hash of bytes parameter, outputs a
[u8; 64]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a keccak 256-bit hash on its bytes parameter, outputs a
[u8; 32]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a keccak 512-bit hash on its bytes parameter, outputs a
[u8; 64]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a sha2 256-bit hash on its bytes parameter, outputs a
[u8; 32]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a XX 64-bit hash on its bytes parameter, outputs a
[u8; 8]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.Apply a XX 128-bit hash on its bytes parameter, outputs a
[u8; 16]
.
Multiple inputs are concatenated before hashing.
Input can be identifier (name of identifier as bytes is used), byte string or
array of bytes.