This commit is contained in:
2020-05-15 01:00:07 +08:00
parent 0fb4016d00
commit b4c30ec23c

View File

@@ -1,3 +1,15 @@
fn main() {
println!("Hello, world!");
use ring::{hmac, rand, error::Unspecified};
fn main() -> Result<(), Unspecified> {
let rng = rand::SystemRandom::new();
let key = hmac::Key::generate(hmac::HMAC_SHA256, &rng)?;
let msg = "hello, world";
let tag = hmac::sign(&key, msg.as_bytes());
println!("{:?}", tag);
hmac::verify(&key, msg.as_bytes(), tag.as_ref())?;
println!("Verify success");
Ok(())
}