Skip to main content

hash

Macro hash 

Source
hash!() { /* proc-macro */ }
Expand description

Hashes literal input at compile time and expands to the canonical Crockford Base32 form as a &'static str.

Accepts a string literal, byte string literal, byte array literal, or byte repeat expression. The expansion equals the runtime ps_hash::hash(input)?.to_string() for the same input. Any other input produces a compile error.

ยงExamples

const HASH: &str = ps_hash_macros::hash!("hello");

assert_eq!(HASH.len(), 77);
assert_eq!(HASH, ps_hash_macros::hash!(b"hello"));
assert_eq!(HASH, ps_hash_macros::hash!([b'h', b'e', b'l', b'l', b'o']));