Skip to content

Commit

Permalink
♻️ use rand_chacha::ChaCha20Rng instead of and::rngs::OsRng
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Oct 21, 2024
1 parent ce1e1a4 commit b648336
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/src/random.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use password_hash::SaltString;
use rand::{rngs::OsRng, RngCore};
use rand::prelude::*;
use rand_chacha::ChaCha20Rng;
use std::io;

pub(crate) fn random_bytes(dist: &mut [u8]) -> io::Result<()> {
let mut rand = OsRng;
let mut rand = ChaCha20Rng::from_entropy();
rand.try_fill_bytes(dist).map_err(io::Error::other)
}

Expand All @@ -14,5 +15,5 @@ pub(crate) fn random_vec(size: usize) -> io::Result<Vec<u8>> {
}

pub(crate) fn salt_string() -> SaltString {
SaltString::generate(OsRng)
SaltString::generate(ChaCha20Rng::from_entropy())
}

0 comments on commit b648336

Please sign in to comment.