Skip to content

Commit

Permalink
One cannot simply appease the linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Dec 29, 2023
1 parent 3753d6b commit d41380d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn totp_generate_tolerance(
) -> Result<String> {
let mut results: Vec<String> = 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)?)
Expand Down Expand Up @@ -150,7 +150,7 @@ fn totp_generate(hex_seed: &str, offset: i64, time_override: Option<i64>) -> 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;
Expand Down

0 comments on commit d41380d

Please sign in to comment.