File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed
EntropyString.playground/Pages/TLDR2.xcplaygroundpage Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change 11//: [Previous](@previous)
22//: ## TLDR 2
33//: ### Take Away
4- //:
54//: - You don't need random strings of length L.
65//: - String length is a by-product, not a goal.
76//: - You don't need truly unique strings.
1211//: - You need to a total of **_N_** strings with a risk **_1/n_** of repeat.
1312//: - The characters are arbitrary.
1413//: - You need `EntropyString`.
14+ //: ##### In a million strings, a 1 in a billion chance of a repeat (using 32 possible characters):
1515import EntropyString
1616
17- let N : Entropy . Power = . ten06
18- let n : Entropy . Power = . ten09
19- var bits = Entropy . bits ( for: N, risk: n)
17+ let bits = Entropy . bits ( for: . ten06, risk: . ten09)
2018let string = RandomString . entropy ( of: bits, using: . charSet32)
2119//: * callout(string): DdHrT2NdrHf8tM
2220
Original file line number Diff line number Diff line change @@ -532,12 +532,11 @@ Note how the number of bytes needed is dependent on the number of characters in
532532 - The characters are arbitrary.
533533 - You need ` EntropyString ` .
534534
535+ ##### In a * million* strings, a * 1 in a billion* chance of a repeat (using 32 possible characters):
535536``` swift
536537 import EntropyString
537538
538- let N: Entropy.Power = .ten06
539- let n: Entropy.Power = .ten09
540- var bits = Entropy.bits (for : N, risk : n)
539+ let bits = Entropy.bits (for : .ten06 , risk : .ten09 )
541540 let string = RandomString.entropy (of : bits, using : .charSet32 )
542541```
543542
You can’t perform that action at this time.
0 commit comments