From ff318d094d75072308f03d7d5f2b829090ed7ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC=20=D0=9F=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=5BArtyom=20Pavlov=5D?= Date: Fri, 21 Jun 2024 17:29:44 +0300 Subject: [PATCH] Add encoding example for sha1-checked --- Cargo.lock | 1 + sha1-checked/Cargo.toml | 1 + sha1-checked/README.md | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index e8d865c0..ed207914 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -276,6 +276,7 @@ dependencies = [ name = "sha1-checked" version = "0.11.0-pre" dependencies = [ + "base16ct", "digest", "hex-literal", "sha1", diff --git a/sha1-checked/Cargo.toml b/sha1-checked/Cargo.toml index c9151d78..a0d47ce0 100644 --- a/sha1-checked/Cargo.toml +++ b/sha1-checked/Cargo.toml @@ -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"] diff --git a/sha1-checked/README.md b/sha1-checked/README.md index f66e34cf..3b58335b 100644 --- a/sha1-checked/README.md +++ b/sha1-checked/README.md @@ -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