Home

Awesome

Cuid2

Pub Version Pub Publisher License

Secure, collision-resistant ids optimized for horizontal scaling and performance. Next generation UUIDs.

Need unique ids in your app? Forget UUIDs and GUIDs which often collide in large apps. Use Cuid2, instead.

Cuid2 is:

Cuid2 is not good for:

Learn more

Install

dart pub add cuid2

Usage

import 'package:cuid2/cuid2.dart';

void main() {
  final id = cuid();  // default options
  final id30 = cuidSecure(30);  // set length to 30, use Random.secure()
  final cc = cuidConfig(length: 30);  // custom config - see example

  print(cc.gen())
  print(id); // eh82waoo5fi41lgncwv5oxxb
  print(id30); // oxjkyfqo3aqk3jigelnuyp3ef299qx
}

Testing

a histogram analysis is done on every batch of tests to ensure a fair and random distribution across the whole entropy range. Any bias found during the analysis would increase the chances of ID collision and cause the tests to fail automatically.

Histogram