forked from EntropyString/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
31 lines (23 loc) · 1.08 KB
/
example.js
File metadata and controls
31 lines (23 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const entropy = require('./entropy-string')
const print = console.log
let bits = 48
print('\n48-bit string using base32 characters')
print(' ' + entropy.string(bits, entropy.charSet32))
print('\n48-bit string using hex characters')
print(' ' + entropy.string(bits, entropy.charSet16))
print('\n48-bit string using uppercase hex characters')
entropy.charSet16.use('1234567890ABCDEF')
print(' ' + entropy.string(bits, entropy.charSet16))
print('\nBase 32 character string with a 1 in a million chance of a repeat in 30 such strings')
bits = entropy.bits(30, 1000000)
print(' ' + entropy.string(bits, entropy.charSet32))
print('\nBase 32 character string with a 1 in a trillion chance of a repeat in 10 million such strings')
bits = entropy.bitsWithPowers(7, 12)
print(' ' + entropy.string(bits, entropy.charSet32))
print('\nAs above, but with "my" base 8 characters')
entropy.charSet8.use('dingosky')
print(' ' + entropy.string(bits, entropy.charSet8))
bits = 128
print('\nOWASP session ID using file system and URL safe characters')
print(' ' + entropy.string(bits, entropy.charSet64))
print('')