aboutsummaryrefslogtreecommitdiff
path: root/src/passwordmaker/mod.rs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2023-01-20 21:03:08 +0100
committerAndreas Grois <andi@grois.info>2023-01-20 21:13:39 +0100
commit212f20c72d703908f6e81b5d569b33d9f5a6ee85 (patch)
tree35e135e437375640cefd62398ad9fabc300891ce /src/passwordmaker/mod.rs
parenta55761caefadafbd88a743dd1f6d5811f6791b86 (diff)
Simplify HMAC function.v0.2.0
It's quite a bit faster, and easier to understand.
Diffstat (limited to 'src/passwordmaker/mod.rs')
-rw-r--r--src/passwordmaker/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/passwordmaker/mod.rs b/src/passwordmaker/mod.rs
index db01a78..e266b2b 100644
--- a/src/passwordmaker/mod.rs
+++ b/src/passwordmaker/mod.rs
@@ -112,7 +112,7 @@ impl<'y, H : super::HasherList> super::PasswordMaker<'y, H>{
let data = leetified_data.as_deref().unwrap_or(data);
let key = yeet_upper_bytes(&key);
let data = yeet_upper_bytes(data);
- let hash = hmac::hmac::<H::MD5,_,_>(key, data);
+ let hash = hmac::hmac::<H::MD5,_>(&key.collect::<Vec<_>>(), data);
let grapheme_indices = hash.convert_to_base(characters.len());
GetGraphemesIterator { graphemes : characters, inner: GetGraphemesIteratorInner::V06(grapheme_indices)}
}
@@ -244,7 +244,7 @@ fn modern_hmac_to_grapheme_indices<T>(key : &str, data: &str, divisor : usize) -
where T:Hasher,
<T as Hasher>::Output: BaseConversion + AsRef<[u8]>
{
- hmac::hmac::<T,_,_>(key.bytes(), data.bytes()).convert_to_base(divisor)
+ hmac::hmac::<T,_>(key.as_bytes(), data.bytes()).convert_to_base(divisor)
}
fn modern_message_to_grapheme_indices<T>(data: &str, divisor : usize) -> <<T as Hasher>::Output as BaseConversion>::Output