Skip to main content

declare_token

Function declare_token 

Source
pub fn declare_token() -> String
Expand description

Declare a fresh success token for one canary run.

This is a nonce, not a secret, and must not be “upgraded” into one. The only property required (RESEARCH § ASVS V6) is that an agent cannot produce the value by chance inside its own generated text. A 64-bit hash of the current wall-clock nanos, this process’s pid and a per-process counter clears that bar by a wide margin, and it costs no new dependency — which is why std::hash::DefaultHasher is used here rather than a CSPRNG crate. Nothing downstream authenticates anything with this value.

Two calls in one process differ because the counter feeds the hash. That makes distinctness overwhelming (a 64-bit collision), not absolute; the token is a nonce and nothing breaks on the ~2⁻⁶⁴ tie.