Add hex-encoding examples based on base16ct (#595)

This commit is contained in:
Artyom Pavlov
2024-06-21 17:49:48 +03:00
committed by GitHub
parent 0b79171da5
commit 89989057f5
44 changed files with 159 additions and 19 deletions

View File

@@ -18,6 +18,7 @@ digest = "=0.11.0-pre.8"
[dev-dependencies]
digest = { version = "=0.11.0-pre.8", features = ["dev"] }
hex-literal = "0.4"
base16ct = { version = "0.2", features = ["alloc"] }
[features]
default = ["oid", "std"]

View File

@@ -20,6 +20,10 @@ hasher.update("The quick brown fox jumps over the lazy dog");
let hash = hasher.finalize();
assert_eq!(hash, hex!("9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76"));
// Hex-encode hash using https://docs.rs/base16ct
let hex_hash = base16ct::lower::encode_string(&hash);
assert_eq!(hex_hash, "9004294a361a508c586fe53d1f1b02746765e71b765472786e4770d565830a76");
```
Also, see the [examples section] in the RustCrypto/hashes readme.