INNER CODE UNIT · Rust

fmt

celabshq/libcrux · benchmarks/src/lib.rs:10

    pub fn fmt(x: usize) -> String {
        let base = (x as f64).log(1024f64).floor() as usize;
        let suffix = ["", "KB", "MB", "GB"];
        format!("{} {}", x >> (10 * base), suffix[base])
    }

    pub fn hex_str_to_bytes(val: &str) -> Vec<u8> {
        let b: Result<Vec<u8>, std::num::ParseIntError> = (0..val.len())
            .step_by(2)
            .map(|i| u8::from_str_radix(&val[i..i + 2], 16))
            .collect();
        b.expect("Error parsing hex string")
    }

    pub fn hex_str_to_array<A>(val: &str) -> A
    where
        A: Default + AsMut<[u8]>,
    {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…