From 9f0f25b98db22ee03395f89dc27c745605d880b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sun, 27 Oct 2024 19:07:13 +0100 Subject: [PATCH] Add Task --- Cargo.toml | 2 ++ src/lib.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 3ba7f96..dbd6d27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,5 @@ license = "MIT OR Apache-2.0" publish = false [dependencies] +pbkdf2 = "0.12.2" +sha2 = "0.10.8" diff --git a/src/lib.rs b/src/lib.rs index e69de29..91334d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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::(self.data, DUMMY_SALT, self.cost, &mut key1); + println!("Task done: {key1:?}"); + } +}