Compare commits
2 commits
b084107e9d
...
6f6f3dc8d3
Author | SHA1 | Date | |
---|---|---|---|
6f6f3dc8d3 | |||
920ff2a2d4 |
2 changed files with 4 additions and 8 deletions
1
Justfile
1
Justfile
|
@ -37,6 +37,7 @@ _default:
|
|||
git init .
|
||||
git checkout -B gh-pages
|
||||
touch .nojekyll
|
||||
echo "lprs.4rs.nl" > CNAME
|
||||
|
||||
git add .
|
||||
git commit -m "Deploy the book to github pages"
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
|
|||
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
|
||||
use base32::Alphabet as Base32Alphabet;
|
||||
use clap::ValueEnum;
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use rand::{thread_rng, RngCore};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{LprsError, LprsResult};
|
||||
|
@ -78,13 +78,8 @@ pub fn totp_now(secret_base32: &str, hash_function: &TotpHash) -> LprsResult<(St
|
|||
///
|
||||
/// Note: The IV will be add it to the end of the ciphertext (Last 16 bytes)
|
||||
pub(crate) fn encrypt(master_password: &[u8; 32], data: &[u8]) -> Vec<u8> {
|
||||
let iv: [u8; 16] = StdRng::seed_from_u64(
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.expect("SystemTime before UNIX EPOCH!")
|
||||
.as_secs(),
|
||||
)
|
||||
.gen();
|
||||
let mut iv = [0u8; 16];
|
||||
thread_rng().fill_bytes(&mut iv);
|
||||
|
||||
let mut ciphertext =
|
||||
Aes256CbcEnc::new(master_password.into(), &iv.into()).encrypt_padded_vec_mut::<Pkcs7>(data);
|
||||
|
|
Loading…
Reference in a new issue