macro_rules! calc_hash {
(MD5: $($input_str:expr),+) => { ... };
(SHA256: $($input_str:expr),+) => { ... };
(SHA384: $($input_str:expr),+) => { ... };
(SHA512: $($input_str:expr),+) => { ... };
(MD5: UPPERCASE => $($input_str:expr),+) => { ... };
(SHA256: UPPERCASE => $($input_str:expr),+) => { ... };
(SHA384: UPPERCASE => $($input_str:expr),+) => { ... };
(SHA512: UPPERCASE => $($input_str:expr),+) => { ... };
(MD5: ITER => $($input_str:expr),+) => { ... };
(SHA256: ITER => $input_iter:expr) => { ... };
(SHA384: ITER => $input_iter:expr) => { ... };
(SHA512: ITER => $input_iter:expr) => { ... };
(MD5: UPPERCASE; ITER => $($input_str:expr),+) => { ... };
(SHA256: UPPERCASE; ITER => $input_iter:expr) => { ... };
(SHA384: UPPERCASE; ITER => $input_iter:expr) => { ... };
(SHA512: UPPERCASE; ITER => $input_iter:expr) => { ... };
(INTERNAL $len:expr; $hasher: expr, $($input_str:expr),+) => { ... };
(INTERNAL $len:expr; UPPERCASE; $hasher: expr, $($input_str:expr),+) => { ... };
(INTERNAL $len:expr; ITER; $hasher: expr, $input_iter:expr) => { ... };
(INTERNAL $len:expr; UPPERCASE; ITER; $hasher: expr, $input_iter:expr) => { ... };
}
Expand description
Calculate Hash.
Returns const_hex::Buffer
, you may use const_hex::Buffer::as_str
to get the string, or just use with str_concat
.
ยงExamples
// General usage. Multiple params supported.
calc_hash!(MD5: "hello", "world");
calc_hash!(SHA256: "hello", "world");
calc_hash!(SHA384: "hello", "world");
calc_hash!(SHA512: "hello", "world");
// You may pass an iterator as input
calc_hash!(MD5: ITER => ["hello", "world"]);
calc_hash!(SHA256: ITER => ["hello", "world"]);
calc_hash!(SHA384: ITER => ["hello", "world"]);
calc_hash!(SHA512: ITER => ["hello", "world"]);
// Uppercase is supported
calc_hash!(SHA256: UPPERCASE => "hello", "world");
// Uppercase with iterator passed in is supported
calc_hash!(SHA256: UPPERCASE; ITER => ["hello", "world"]);