Skip to content

Commit 8a1a5bf

Browse files
author
Piyush Bhatt
committed
Update README
1 parent 315addd commit 8a1a5bf

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Deno module based on [crypto-random-string](https://github.com/sindresorhus/crypto-random-string). Useful for creating an identifier, slug, salt, PIN code, fixture, etc.
66

77
## Import Module
8+
---
89

910
```typescript
1011
import { cryptoRandomString, cryptoRandomStringAsync } from "https://deno.land/x/[email protected]/mod.ts"
@@ -13,35 +14,49 @@ import { cryptoRandomString, cryptoRandomStringAsync } from "https://github.com/
1314
```
1415

1516
## Usage
17+
---
18+
19+
**NOTE:** Outputs shown below are merely examples. The function will generate random string each time.
20+
1621

1722
```typescript
1823

19-
cryptoRandomString({length: 10});
20-
//=> '2cf05d94db'
24+
cryptoRandomString({length: 10}); // '0696cb9e70'
25+
26+
await cryptoRandomStringAsync({length: 10}); // 'c8d4b0140d'
27+
28+
cryptoRandomString({length: 10, type: 'base64'}); // 'dw3mgWC5uO'
29+
30+
await cryptoRandomStringAsync({length: 10, type: 'base64'}); // 'k6ALljZx+E'
31+
32+
cryptoRandomString({length: 10, type: 'url-safe'}); // '0pN1Y2Jz.X'
33+
34+
await cryptoRandomStringAsync({length: 10, type: 'url-safe'}); // '7.F5oBY9Qy'
35+
36+
cryptoRandomString({length: 10, type: 'numeric'}); // '1639380067'
37+
38+
await cryptoRandomStringAsync({length: 10, type: 'numeric'}); // '0923903115'
39+
40+
cryptoRandomString({length: 6, type: 'distinguishable'}); // 'H4HH5D'
41+
42+
await cryptoRandomStringAsync({length: 6, type: 'distinguishable'}); // 'D2Y254'
2143

22-
cryptoRandomString({length: 10, type: 'base64'});
23-
//=> 'YMiMbaQl6I'
44+
cryptoRandomString({length: 10, type: 'ascii-printable'}); // '#I&J.GP./9'
2445

25-
cryptoRandomString({length: 10, type: 'url-safe'});
26-
//=> 'YN-tqc8pOw'
46+
await cryptoRandomStringAsync({length: 10, type: 'ascii-printable'}); // '7t%FxZkyL('
2747

28-
cryptoRandomString({length: 10, type: 'numeric'});
29-
//=> '8314659141'
48+
cryptoRandomString({length: 10, type: 'alphanumeric'}); // 'ZtgC2J6aU5'
3049

31-
cryptoRandomString({length: 6, type: 'distinguishable'});
32-
//=> 'CDEHKM'
50+
await cryptoRandomStringAsync({length: 10, type: 'alphanumeric'}); // 'FELQVN9S8H'
3351

34-
cryptoRandomString({length: 10, type: 'ascii-printable'});
35-
//=> '`#Rt8$IK>B'
52+
cryptoRandomString({length: 10, characters: 'abc'}); // 'abcabccbcc'
3653

37-
cryptoRandomString({length: 10, type: 'alphanumeric'});
38-
//=> 'DMuKL8YtE7'
54+
await cryptoRandomStringAsync({length: 10, characters: 'abc'}); // 'abcbbbacbb'
3955

40-
cryptoRandomString({length: 10, characters: 'abc'});
41-
//=> 'abaaccabac'
4256
```
4357

4458
## API
59+
---
4560

4661
### cryptoRandomString(options)
4762

@@ -89,5 +104,6 @@ Use only characters from a custom set of allowed characters.
89104
Cannot be set at the same time as the `type` option.
90105

91106
## Licensing
107+
---
92108

93109
[MIT](https://github.com/piyush-bhatt/crypto-random-string/blob/main/LICENSE) licensed

0 commit comments

Comments
 (0)