keyfork/crates/util/keyfork-plumbing/src/bin/keyfork-entropy.rs

21 lines
563 B
Rust
Raw Normal View History

fn main() -> Result<(), Box<dyn std::error::Error>> {
let bit_size: usize = std::env::args()
.nth(1)
.unwrap_or(String::from("256"))
.parse()
.expect("Expected integer bit size");
assert!(
bit_size % 8 == 0,
"Bit size must be divisible by 8, got: {bit_size}"
);
assert!(
bit_size <= 256,
"Maximum supported bit size is 256, got: {bit_size}"
);
let entropy = keyfork_entropy::generate_entropy_of_size(bit_size / 8)?;
println!("{}", smex::encode(&entropy));
Ok(())
}