Skip to content

Commit

Permalink
Basic implemention
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Apr 2, 2018
1 parent 2e42172 commit b50f491
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/nanoid.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'dart:math';

String url = '_~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
Random r = new Random.secure();

String nanoid([int size = 21]) {
String id = '';
while (0 < size--) {
id += url[r.nextInt(64)];
}
return id;
}
8 changes: 8 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: nanoid
version: 0.0.1
author: Rongjian Zhang <pd4d10@gmail.com>
description: A secure, URL-friendly, unique string ID generator
homepage: https://github.com/pd4d10/nanoid

environment:
sdk: ">=2.0.0-dev.32.0 <2.0.0"

0 comments on commit b50f491

Please sign in to comment.