diff --git a/src/hashutils.rs b/src/hashutils.rs index 865d8d5..ae6fb2a 100644 --- a/src/hashutils.rs +++ b/src/hashutils.rs @@ -1,5 +1,5 @@ -use ring::digest::{ Algorithm, Context }; +use ring::digest::{ Algorithm, digest }; /// The sole purpose of this trait is to extend the standard /// `ring::algo::Algorithm` type with a couple utility functions. @@ -15,16 +15,12 @@ pub trait HashUtils { impl HashUtils for Algorithm { fn hash_bytes(&'static self, bytes: &[u8]) -> Vec { - let mut context = Context::new(self); - context.update(bytes); - context.finish().as_ref().into() + digest(self, bytes).as_ref().into() } fn combine_hashes(&'static self, left: &[u8], right: &[u8]) -> Vec { - let mut context = Context::new(self); let combined = [left, right].concat(); - context.update(&combined); - context.finish().as_ref().into() + digest(self, &combined).as_ref().into() } }