This commit is contained in:
Rodolphe Bréard 2024-10-27 19:07:13 +01:00
parent bac7f922aa
commit 9f0f25b98d
2 changed files with 23 additions and 0 deletions

View file

@ -8,3 +8,5 @@ license = "MIT OR Apache-2.0"
publish = false
[dependencies]
pbkdf2 = "0.12.2"
sha2 = "0.10.8"

View file

@ -0,0 +1,21 @@
use pbkdf2::pbkdf2_hmac;
use sha2::Sha256;
const DUMMY_SALT: &[u8] = b"some dummy salt";
pub struct Task {
data: &'static [u8],
cost: u32,
}
impl Task {
pub fn new(data: &'static [u8], cost: u32) -> Self {
Self { data, cost }
}
pub fn execute(&self) {
let mut key1 = [0u8; 20];
pbkdf2_hmac::<Sha256>(self.data, DUMMY_SALT, self.cost, &mut key1);
println!("Task done: {key1:?}");
}
}