Expand description
§pepperflake
Fast, unforgeable, sortable 64-bit ID generation.
§Bit layout (Default)
63 20 19 6 5 0
|------- time (44b) ------|-- rand (14b) -|- check (6b) -|- 44 bits — millisecond timestamp via
CLOCK_REALTIME_COARSE - 14 bits — xorshift random tail (16,384 slots per ms tick)
- 6 bits — checksum seeded with secret pepper (rejects ~98.4% of fake IDs)
§Usage
use pepperflake::{generate, is_valid, configure};
// Optional: Reconfigure bit layout on startup
// configure(12, 8);
let id = generate();
assert!(is_valid(id));Functions§
- configure
- Adjust the bit allocation for randomness and checksums.
- generate
- Generate a new ID.
- is_
valid - Validate an ID.
- random_
part - Extract the random component of an ID.
- set_
pepper - Change the secret pepper used for checksums.
- timestamp_
millis - Extract the Unix epoch timestamp in milliseconds embedded in an ID.