Small and fast collision resistant id generator
A: We wanted a fast and low maintenance, url friendly id generator.
const smallId = ;const id = ;const getSafeId = async await smallId;
Generator uses a pallet of URL friendly characters
- The ids are generated from the current timestamp with an appended 3 digit counter
- The counter increments with each call and reset when it hits 1000
- You should not use those ids for serious cryptographic purposes, since they can give away the timestamp at which they were generated.
A word about the collision resistance
In case of single source of generation the ids are:
- collision-resistant if you generate less than 1000 per second
- collision-proof if you use
await smallId.safe()defers the generation process by a millisecond if the counter rolled over
In case of multiple sources of generation it's advised to also use a source identifier with the ids, then same rules as above apply.
License can be found here