-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
65 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'dart:math'; | ||
import 'package:nanoid/src/url_alphabet.dart'; | ||
export 'package:nanoid/src/url_alphabet.dart'; | ||
|
||
final _random = Random.secure(); | ||
|
||
Future<String> nanoid([int size = 21]) async { | ||
return customAlphabet(urlAlphabet, size); | ||
} | ||
|
||
Future<String> customAlphabet(String alphabet, int size) async { | ||
final len = alphabet.length; | ||
String id = ''; | ||
while (0 < size--) { | ||
id += alphabet[_random.nextInt(len)]; | ||
} | ||
return id; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import 'generate.dart'; | ||
import 'url.dart'; | ||
import 'dart:math'; | ||
import 'package:nanoid/src/url_alphabet.dart'; | ||
export 'package:nanoid/src/url_alphabet.dart'; | ||
|
||
final _random = Random.secure(); | ||
|
||
String nanoid([int size = 21]) { | ||
return generate(url, size); | ||
return customAlphabet(urlAlphabet, size); | ||
} | ||
|
||
String customAlphabet(String alphabet, int size) { | ||
final len = alphabet.length; | ||
String id = ''; | ||
while (0 < size--) { | ||
id += alphabet[_random.nextInt(len)]; | ||
} | ||
return id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'dart:math'; | ||
import 'package:nanoid/src/url_alphabet.dart'; | ||
export 'package:nanoid/src/url_alphabet.dart'; | ||
|
||
final _random = Random(); | ||
|
||
String nanoid([int size = 21]) { | ||
return customAlphabet(urlAlphabet, size); | ||
} | ||
|
||
String customAlphabet(String alphabet, int size) { | ||
final len = alphabet.length; | ||
String id = ''; | ||
while (0 < size--) { | ||
id += alphabet[_random.nextInt(len)]; | ||
} | ||
return id; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const urlAlphabet = | ||
'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
name: nanoid | ||
version: 0.2.0 | ||
author: Rongjian Zhang <pd4d10@gmail.com> | ||
description: A tiny, secure, URL-friendly, unique string ID generator. Dart implementation of ai/nanoid | ||
homepage: https://github.com/pd4d10/nanoid-dart | ||
|
||
environment: | ||
sdk: ">=2.12.0-0 <3.0.0" | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dev_dependencies: | ||
test: ^1.16.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters