cuid2 library
cuid2
is a Dart implementation of the cuid2 library.
For technical details is recommended to check the original documentation where the inner details are explained.
Example usage:
// cuid generator
print(cuid()); // => cl8qj639w000l7n6e6p689uad
// cuid using secure random generator
print(cuidSecure()); // => cl8qjcei8000kfq6e3a1q19os
// custom id length (defaults to 24)
print(cuid(30)); // => oxjkyfqo3aqk3jigelnuyp3ef299qx
final myCuid = cuidConfig(length: 30);
final id = myCuid.gen();
Functions
-
cuid(
[int length = 24]) → String - Generates a new id (default length of 24).
-
cuidConfig(
{int length = 24, int counter()?, String fingerprint()?, bool secure = false}) → Cuid - Creates a generator with the given options.
-
cuidSecure(
[int length = 24]) → String - Generates a new id using cryptographic random generator (default length of 24).
-
isCuid(
String id, {int minLength = 2, int maxLength = 32}) → bool -
Determines if the given string
id
is a valid CUID based on the specified length constraints.