Skip to content

Commit ff318d0

Browse files
committed
Add encoding example for sha1-checked
1 parent 5ea05bc commit ff318d0

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sha1-checked/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ zeroize = { version = "1.8", default-features = false, optional = true }
2525
[dev-dependencies]
2626
digest = { version = "=0.11.0-pre.8", features = ["dev"] }
2727
hex-literal = "0.4"
28+
base16ct = { version = "0.2", features = ["alloc"] }
2829

2930
[features]
3031
default = ["oid", "std"]

sha1-checked/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ use sha1_checked::Sha1;
3232
let result = Sha1::try_digest(b"hello world");
3333
assert_eq!(result.hash().as_ref(), hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"));
3434
assert!(!result.has_collision());
35+
36+
// Hex-encode hash using https://docs.rs/base16ct
37+
let hex_hash = base16ct::lower::encode_string(result.hash().as_ref());
38+
assert_eq!(hex_hash, "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed");
3539
```
3640

3741
### Incremental API

0 commit comments

Comments
 (0)