You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The available CharSets are `base64`, `base32`, `base16`, `base8`, `base4` and `base2`. The default characters for each were chosen as follows:
265
+
The available CharSets are `base64`, `base32`, `base16`, `base8`, `base4` and `base2`. For convenience, the character sets are also exported as `random` fields `charSet64`, `charSet32`, `charSet16`, `charSet8`, `charSet4` and `charSet2`. The default characters for each were chosen as follows:
* The file system and URL safe char set from [RFC 4648](https://tools.ietf.org/html/rfc4648#section-5).
@@ -289,37 +292,36 @@ Being able to easily generate random strings is great, but what if you want to s
289
292
290
293
```js
291
294
constrandom=require('entropy-string').random
292
-
constCharSet=require('entropy-string').CharSet
293
-
let flips =random.string(10, CharSet.base2)
295
+
296
+
let flips =random.string(10, random.charSet2)
294
297
```
295
298
296
299
> flips: 1111001011
297
300
298
301
The resulting string of __0__'s and __1__'s doesn't look quite right. Perhaps you want to use the characters __H__ and __T__ instead.
299
302
300
303
```js
301
-
CharSet.base2.use('HT')
302
-
flips =random.string(10, CharSet.base2)
304
+
random.charSet2.use('HT')
305
+
flips =random.string(10, random.charSet2)
303
306
```
304
307
305
308
> flips: THHTHTTHHT
306
309
307
310
As another example, we saw in [Character Sets](#CharacterSets) the default characters for CharSet 16 are **0123456789abcdef**. Suppose you like uppercase hexadecimal letters instead.
308
311
309
312
```js
310
-
CharSet.base16.use('0123456789ABCDEF')
311
-
let string =random.string(48, CharSet.base16)
313
+
random.charSet16.use('0123456789ABCDEF')
314
+
let string =random.string(48, random.charSet16)
312
315
313
316
```
314
317
315
318
> string: 08BB82C0056A
316
319
317
-
`CharSet.baseNN.use(string)` throws an `Error` if the number of characters doesn't match the number required for the CharSet or if the characters are not all unique.
320
+
`random.charSetNN.use(string)` throws an `Error` if the number of characters doesn't match the number required for the CharSet or if the characters are not all unique.
318
321
319
322
```js
320
-
constCharSet=require('entropy-string').CharSet
321
323
try {
322
-
CharSet.base8.use('abcdefh')
324
+
random.charSet8.use('abcdefh')
323
325
}
324
326
catch(error) {
325
327
console.log(error.message)
@@ -330,7 +332,7 @@ As another example, we saw in [Character Sets](#CharacterSets) the default chara
330
332
331
333
```js
332
334
try {
333
-
CharSet.base8.use('01233210')
335
+
random.charSet8.use('01233210')
334
336
}
335
337
catch(error) {
336
338
console.log(error.message)
@@ -408,7 +410,7 @@ The __bytes__ provided can come from any source. However, the number of bytes mu
0 commit comments