sha1-macros

Crates.iosha1-macros
lib.rssha1-macros
version1.0.0
sourcesrc
created_at2024-04-07 19:39:33.165644
updated_at2024-04-07 19:39:33.165644
descriptionMacros for computing SHA1 hashes at compile-time
homepage
repositoryhttps://github.com/xoddiel/sha1-macros
max_upload_size
id1199466
size5,090
Xoddiel d'Croy (xoddiel)

documentation

README

SHA1 macros

The sha1-macros crate allows you to compute SHA1 hashes at compile-time.

assert_eq!(sha1_hex!("this is a test"), "fa26be19de6bff93f70bc2308434e4a440bbad02");
assert_eq!(sha1_bytes!("this is a test"), hex!("fa26be19de6bff93f70bc2308434e4a440bbad02"));

Why macros and not const fn?

Simple answer: It is not yet possible to create a &'static str at compile-time using const fn. By providing macros, we remove the need to encode your hash digest into hex or base64 at runtime. Note that this has the limitation that the input of sha1_* macros must be either a string ("value") or a byte (b"value") literal. It cannot be a const value.

Commit count: 1

cargo fmt