add ring::sha256
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
use ring::{hmac, rand, error::Unspecified};
|
||||
use ring::{
|
||||
hmac, rand, error::Unspecified,
|
||||
digest,
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Unspecified> {
|
||||
{
|
||||
println!("{} HHmac {}", "-".repeat(10), "-".repeat(10));
|
||||
let rng = rand::SystemRandom::new();
|
||||
let key = hmac::Key::generate(hmac::HMAC_SHA256, &rng)?;
|
||||
|
||||
@@ -10,6 +15,12 @@ fn main() -> Result<(), Unspecified> {
|
||||
println!("{:?}", tag);
|
||||
hmac::verify(&key, msg.as_bytes(), tag.as_ref())?;
|
||||
println!("Verify success");
|
||||
}
|
||||
{
|
||||
println!("{} SHA256 {}", "-".repeat(10), "-".repeat(10));
|
||||
let sha256 = digest::digest(&digest::SHA256, b"hello, world");
|
||||
println!("{:?}", sha256);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user