diff --git a/ring/src/main.rs b/ring/src/main.rs index e7a11a9..02df33e 100644 --- a/ring/src/main.rs +++ b/ring/src/main.rs @@ -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(()) }