Compute SHA-256 of the token bytes. Used as the stable identity for state-machine tracking (never stores the raw token).
(token_hex: &str)
| 87 | /// Compute SHA-256 of the token bytes. Used as the stable identity for |
| 88 | /// state-machine tracking (never stores the raw token). |
| 89 | pub fn token_hash(token_hex: &str) -> Result<[u8; 32], TokenError> { |
| 90 | use sha2::Digest; |
| 91 | let bytes = hex_decode(token_hex)?; |
| 92 | Ok(sha2::Sha256::digest(&bytes).into()) |
| 93 | } |
| 94 | |
| 95 | /// Verify a hex-encoded token against `secret`. Returns the bound |
| 96 | /// `(for_node, expiry_unix_secs)` on success. |