Encode raw token bytes as a lowercase hex string.
(bytes: &[u8])
| 76 | |
| 77 | /// Encode raw token bytes as a lowercase hex string. |
| 78 | pub fn token_to_hex(bytes: &[u8]) -> String { |
| 79 | use std::fmt::Write as _; |
| 80 | let mut out = String::with_capacity(bytes.len() * 2); |
| 81 | for b in bytes { |
| 82 | let _ = write!(out, "{b:02x}"); |
| 83 | } |
| 84 | out |
| 85 | } |
| 86 | |
| 87 | /// Compute SHA-256 of the token bytes. Used as the stable identity for |
| 88 | /// state-machine tracking (never stores the raw token). |