Alphabets v0.1.0
NanoIdAlphabet
pub const NanoIdAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
Nano ID's default alphabet: the sixty-four URL-safe characters A–Z, a–z, 0–9, _ and -.
Listed in the reference implementation's order, so the same random bytes give the same identifier here as there.
NanoIdLength
pub const NanoIdLength: uint = 21;
The default identifier length, in characters: twenty-one. Twenty-one characters of the default alphabet carry 126 random bits, more than the 122 of a version 4 UUID, in twenty-one characters where the UUID takes thirty-six.
ValidateAlphabet
pub func ValidateAlphabet(alphabet: char8[..]) -> ! NanoIdError
Checks that alphabet can be drawn from without bias.
It must hold between two and 256 characters, all ASCII and all distinct. Reports AlphabetTooSmall,
AlphabetTooLarge, NonAsciiCharacter or DuplicateCharacter, the last two with the offset of the offending
byte. Runs in time linear in the alphabet's length and allocates nothing.
Parameters
| Name | Type | Description |
|---|---|---|
alphabet | char8[..] | the characters an identifier would be drawn from |
Returns: success when the alphabet is usable