mirror of
https://github.com/RustCrypto/hashes.git
synced 2026-01-25 04:18:20 +00:00
Add hex-encoding examples based on base16ct (#595)
This commit is contained in:
@@ -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"]
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user