refactor: simplify hash_token using format macro
Replace manual hex encoding loop with `format!("{:x}", Sha256::digest(...))`,
which is more idiomatic and concise.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
b3bfbaff4a
commit
23048d10ac
1 changed files with 1 additions and 7 deletions
|
|
@ -195,13 +195,7 @@ fn generate_token() -> String {
|
|||
|
||||
/// SHA-256 hash a bearer token for storage. Returns lowercase hex.
|
||||
fn hash_token(token: &str) -> String {
|
||||
let digest = Sha256::digest(token.as_bytes());
|
||||
let mut hex = String::with_capacity(64);
|
||||
for b in digest {
|
||||
use std::fmt::Write;
|
||||
let _ = write!(hex, "{b:02x}");
|
||||
}
|
||||
hex
|
||||
format!("{:x}", Sha256::digest(token.as_bytes()))
|
||||
}
|
||||
|
||||
/// Check if a stored value looks like a SHA-256 hash (64 hex chars)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue