use cas_lib::{password_hashers::{argon2::CASArgon, cas_password_hasher::CASPasswordHasher}, symmetric::{aes::CASAES256, cas_symmetric_encryption::CASAESEncryption}};
use pbkdf2::pbkdf2_hmac_array;
use sha2::Sha256;
fn main() {
let bad_password = CASArgon::hash_password("welcome home".to_string());
let bad_password_bytes = bad_password.as_bytes();
let salt = b"salt";
// number of iterations
let n = 600_000;
let key = pbkdf2_hmac_array::<Sha256, 32>(bad_password_bytes, salt, n).to_vec();
let nonce = CASAES256::generate_nonce();
let data_to_encrypt = "welcome home".as_bytes().to_vec();
let encrypted = CASAES256::encrypt_plaintext(key.clone(), nonce.clone(), data_to_encrypt.clone());
let decrypted = CASAES256::decrypt_ciphertext(key, nonce, encrypted);
assert_eq!(decrypted, data_to_encrypt)
}
This is something that i have been meaning to get around too. This will be useful for "master" password derivations.
https://docs.rs/pbkdf2/latest/pbkdf2/ https://github.com/RustCrypto/password-hashes/tree/master/pbkdf2