var uniqueKey = require('unique-key');
uniqueKey(); // lAKy6I1wpDu06VrN
uniqueKey(32); // JOOyujJuSxTH4IPeYBZ7jGbYh1XivKFH
uniqueKey('key_'); // key_Y9swzmCrJuhphnfS
uniqueKey(64, 'pk-'); // pk-EzUXF6tGVcQ1BB7MildOmW3z79tdf5t50JO8qw1pImz76W4icuPol7XcWborLqfj
uniqueKey({
size: 36,
prefix: 'pk_',
}); // pk_SRemDxNIjgzyuFYrHTEYJBeh9WdZbBlTpqup
uniqueKey({
size: 24, // Optional size of key to geneate. Default is 16
prefix: 'sk_', // Optional
charType: 'alphanum', // Optional numeric || alphanum (default) || alpha
transform: 'lower', // Optional lower || upper
}); // sk_cvwjyzu2zsqsrfhgm9zsclxb
The keys generated are not in any sense unique! You may have to check against a database to ensure uniqueness