initial commit

This commit is contained in:
Maciej Lebiest 2024-12-04 19:13:42 +01:00
parent 62c79042e1
commit 42a91e54b6
2 changed files with 29 additions and 0 deletions

8
Cargo.toml Normal file
View file

@ -0,0 +1,8 @@
[package]
name = "rust-crypto-tests"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"
rsa = "0.9.7"

21
src/main.rs Normal file
View file

@ -0,0 +1,21 @@
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);
}