Move the task struct to a dedicated module
This commit is contained in:
parent
5380bb7d55
commit
ec74847e63
2 changed files with 23 additions and 20 deletions
22
src/lib.rs
22
src/lib.rs
|
@ -1,23 +1,5 @@
|
||||||
pub mod algorithm;
|
pub mod algorithm;
|
||||||
pub mod data;
|
pub mod data;
|
||||||
|
pub mod task;
|
||||||
|
|
||||||
use pbkdf2::pbkdf2_hmac;
|
pub use task::Task;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
21
src/task.rs
Normal file
21
src/task.rs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
use pbkdf2::pbkdf2_hmac;
|
||||||
|
use sha2::Sha256;
|
||||||
|
|
||||||
|
const DUMMY_SALT: &[u8] = b"some dummy salt";
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Task {
|
||||||
|
pub data: &'static [u8],
|
||||||
|
pub 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue