Merge pull request #755 from zeroclaw-labs/ISSUE-754
fix(token): update token generation to use rand::rng() Addresses warning coming from compiler: ❯ rspberrypi@localhost:~/zeroclaw$ cargo build --release --locked warning: use of deprecated function rand::thread_rng: Renamed to rng --> src/security/pairing.rs:186:11 | 186 | rand::thread_rng().fill_bytes(&mut bytes); | ^^^^^^^^^^ | = note: #[warn(deprecated)] on by default
This commit is contained in:
commit
9f34e2465e
1 changed files with 2 additions and 2 deletions
|
|
@ -176,14 +176,14 @@ fn generate_code() -> String {
|
|||
|
||||
/// Generate a cryptographically-adequate bearer token with 256-bit entropy.
|
||||
///
|
||||
/// Uses `rand::thread_rng()` which is backed by the OS CSPRNG
|
||||
/// Uses `rand::rng()` which is backed by the OS CSPRNG
|
||||
/// (/dev/urandom on Linux, BCryptGenRandom on Windows, SecRandomCopyBytes
|
||||
/// on macOS). The 32 random bytes (256 bits) are hex-encoded for a
|
||||
/// 64-character token, providing 256 bits of entropy.
|
||||
fn generate_token() -> String {
|
||||
use rand::RngCore;
|
||||
let mut bytes = [0u8; 32];
|
||||
rand::thread_rng().fill_bytes(&mut bytes);
|
||||
rand::rng().fill_bytes(&mut bytes);
|
||||
format!("zc_{}", hex::encode(bytes))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue