MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / token_hash

Function token_hash

nodedb-cluster/src/auth/join_token.rs:89–93  ·  view source on GitHub ↗

Compute SHA-256 of the token bytes. Used as the stable identity for state-machine tracking (never stores the raw token).

(token_hex: &str)

Source from the content-addressed store, hash-verified

87/// Compute SHA-256 of the token bytes. Used as the stable identity for
88/// state-machine tracking (never stores the raw token).
89pub 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.

Callers 2

token_hash_stableFunction · 0.85
handleMethod · 0.85

Calls 1

hex_decodeFunction · 0.70

Tested by 2

token_hash_stableFunction · 0.68
handleMethod · 0.68