rust-crypto-tests/src/main.rs

22 lines
641 B
Rust
Raw Normal View History

2024-12-04 18:13:42 +00:00
use rsa::{RsaPrivateKey, RsaPublicKey};
use std::time::Instant;
use rand::rngs::OsRng;
fn generate_rsa_keys(count: usize, key_size: usize) -> Vec<(RsaPrivateKey, RsaPublicKey)> {
let mut rng = OsRng;
(0..count)
.map(|_| {
let private_key = RsaPrivateKey::new(&mut rng, key_size).expect("Failed to generate a key");
let public_key = RsaPublicKey::from(&private_key);
(private_key, public_key)
})
.collect()
}
fn main() {
let start = Instant::now();
generate_rsa_keys(10, 2048);
let duration = start.elapsed();
println!("Execution time: {:?}", duration);
}