From d41380d3867d797cff57783a5ffcb21350c9e7a2 Mon Sep 17 00:00:00 2001 From: itsmeow Date: Fri, 29 Dec 2023 01:45:49 -0500 Subject: [PATCH] One cannot simply appease the linter. --- src/hash.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hash.rs b/src/hash.rs index 349a8ea2..7980e741 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -102,7 +102,7 @@ fn totp_generate_tolerance( ) -> Result { let mut results: Vec = Vec::new(); for i in -tolerance..(tolerance + 1) { - let result = totp_generate(hex_seed, i.into(), time_override)?; + let result = totp_generate(hex_seed, i.try_into().unwrap(), time_override)?; results.push(result) } Ok(serde_json::to_string(&results)?) @@ -150,7 +150,7 @@ fn totp_generate(hex_seed: &str, offset: i64, time_override: Option) -> Res let offset: usize = (hmac[19] & 0x0F).into(); - let result_bytes: [u8; 4] = hmac[offset..(offset + 4)].into(); + let result_bytes: [u8; 4] = hmac[offset..(offset + 4)].try_into().unwrap(); let full_result: u32 = u32::from_be_bytes(result_bytes); let result: u32 = (full_result & 0x7FFFFFFF) % 1000000;