From 23048d10ac07fbc0b84603a6c1ce13396ad7c280 Mon Sep 17 00:00:00 2001 From: fettpl <38704082+fettpl@users.noreply.github.com> Date: Sun, 15 Feb 2026 00:28:04 +0100 Subject: [PATCH] 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 --- src/security/pairing.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/security/pairing.rs b/src/security/pairing.rs index e8d946c..dd5f2eb 100644 --- a/src/security/pairing.rs +++ b/src/security/pairing.rs @@ -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)