3 stable releases

7.0.0 Feb 26, 2023
6.0.0 Dec 14, 2022
5.0.0 Mar 1, 2022

#309 in #node

Download history 5/week @ 2022-12-01 322/week @ 2022-12-08 1675/week @ 2022-12-15 353/week @ 2022-12-22 133/week @ 2022-12-29 593/week @ 2023-01-05 442/week @ 2023-01-12 726/week @ 2023-01-19 882/week @ 2023-01-26 789/week @ 2023-02-02 570/week @ 2023-02-09 836/week @ 2023-02-16 2710/week @ 2023-02-23 995/week @ 2023-03-02 261/week @ 2023-03-09 405/week @ 2023-03-16

4,448 downloads per month
Used in 163 crates (3 directly)

Apache-2.0

17KB
217 lines

sp-core-hashing-proc-macro

Auto-generated README.md for publishing to crates.io


lib.rs:

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"),
);

Dependencies

~2.5MB
~42K SLoC