Skip to content

Commit

Permalink
Minor tweaks and improvements to code.
Browse files Browse the repository at this point in the history
  • Loading branch information
sciguyryan committed Jan 25, 2024
1 parent 439c29b commit 27b2ad2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions psistega3-core/src/utilities/misc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,13 @@ pub(crate) fn u8_slice_to_hex(slice: &[u8], uppercase: bool) -> String {
///
#[inline]
pub(crate) fn u8_slice_to_u64(bytes: &[u8]) -> u64 {
use byteorder::{LittleEndian, ReadBytesExt};

assert!(
bytes.len() == 64,
"Byte vector is not 64 bytes (512-bits) in length."
);

let mut rdr = std::io::Cursor::new(bytes);
let seed = rdr.read_u64::<LittleEndian>();
assert!(seed.is_ok(), "Failed to create a u64 from the key bytes.");

seed.unwrap()
let arr = <[u8; 8]>::try_from(&bytes[0..8]).expect("slice with incorrect length");
u64::from_le_bytes(arr)
}

/// Convert a u8 value into its binary representation.
Expand Down

0 comments on commit 27b2ad2

Please sign in to comment.