Skip to content

Commit

Permalink
Add encoding example for sha1-checked
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Jun 21, 2024
1 parent 5ea05bc commit ff318d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sha1-checked/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ zeroize = { version = "1.8", default-features = false, optional = true }
[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"]
Expand Down
4 changes: 4 additions & 0 deletions sha1-checked/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ use sha1_checked::Sha1;
let result = Sha1::try_digest(b"hello world");
assert_eq!(result.hash().as_ref(), hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed"));
assert!(!result.has_collision());

// Hex-encode hash using https://docs.rs/base16ct
let hex_hash = base16ct::lower::encode_string(result.hash().as_ref());
assert_eq!(hex_hash, "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed");
```

### Incremental API
Expand Down

0 comments on commit ff318d0

Please sign in to comment.