All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 10m26s
19 lines
458 B
Rust
19 lines
458 B
Rust
use rand::Rng;
|
|
use sha2::{Digest, Sha256};
|
|
pub fn generate_refresh_token() -> (String, String) {
|
|
let mut bytes = [0u8; 32];
|
|
|
|
let mut thread_rng = rand::rng();
|
|
thread_rng.fill_bytes(&mut bytes);
|
|
|
|
let plain = hex::encode(&bytes); // 64 hex chars for user
|
|
let hash = {
|
|
// SHA-256 for DB storage
|
|
let mut hasher = Sha256::new();
|
|
hasher.update(&plain);
|
|
hex::encode(hasher.finalize())
|
|
};
|
|
|
|
(plain, hash)
|
|
}
|