Function chewdata::helper::checksum::str_to_hasher_with_checksum
source · pub fn str_to_hasher_with_checksum(
algo_with_checksum: &str
) -> Result<(Box<dyn DynDigest>, Option<&str>)>
Expand description
Transform str to a tuple (hasher, checksum).
Arguments:
algo_with_checksum
- A string slice that contain the ‘algorithm:checksum’ or only the ‘algorithm’.
§Examples
use chewdata::helper::checksum::str_to_hasher_with_checksum;
use sha3::Sha3_256Core;
use sha3::digest::OutputSizeUser;
let result = str_to_hasher_with_checksum("sha256:abcdef1234567890");
assert!(result.is_ok());
let (hasher, checksum) = result.unwrap();
assert_eq!(hasher.output_size(), Sha3_256Core::output_size());
assert_eq!(checksum, Some("abcdef1234567890"));