A minimal BIP39 compatible library for generation of common words as password or BIP39 mnemonic.
git clone --depth 1 git@github.com:Sajjon/VanligaOrd.git && cd VanligaOrd && sh generate.sh
Reddit user HelmedHorror
has created this amazing table about password strength.
In 2012 a cluster of 25 GPUs achived a hashrate of 10^12. Due to exponential growth in computer power (Mooreโs law), we are over 10^13 in 2019 (time of writing). To generate a safe password it is thus recommended you achive 80 bits of entropy.
Bits | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 76 | 78 | 80 | 82 | 84 | 86 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Time until cracked | 13 h | 2 d | 8 d | 34 d | 4 m | 1 y | 6 y | 24 y | 96 y | 383 y | 1,500 y | 6,100 y | 25,000 y | 98,000 y |
#Words needed (wordlist of size 2048) | 6 | 6 | 6 | 6 | 7 | 7 | 7 | 7 | 7 | 8 | 8 | 8 | 8 | 8 |
swift run GeneratePassword --words 8 | less
The piping to less
is of course optional - but recommended for maximum security (it automatically clears the password from your screen after you press Q
to exit less
).
Or use the shell script:
sh generate.sh
Installable via Swift Package Manager (SPM):
From Xcode 11, you can use SPM to add VanligaOrd
to your project:
- Select File > Swift Packages > Add Package Dependency, Enter
https://github.com/Sajjon/VanligaOrd.git
in the "Choose Package Repository" dialog. - In the next page, specify the version resolving rule as "Up to Next Major" with "0.0.1" as its earliest version.
- After Xcode checking out the source and resolving the version, you can choose the "VanligaOrd" library and add it to your app target.
If you encounter any problem or have a question on adding package to an Xcode project, take a look at the Adding Package Dependencies to Your App guide article from Apple.
- or -
Add in your Package.swift
file
dependencies: [
.package(url: "https://github.com/Sajjon/VanligaOrd", from: "0.0.1"),
],
All BIP39 languages are supported, which are:
- ๐จ๐ณ Chinese (simplified and traditional)
- ๐จ๐ฟ Czech
- ๐ฌ๐ง English
- ๐ซ๐ท French
- ๐ฎ๐น Italian
- ๐ฏ๐ต Japanese
- ๐ฐ๐ท Korean.
- ๐ช๐ธ Spanish
Support coming soon, stay tuned ๐ฃ.
You can either generate a password by specifying the number of words you want.
let passwordGenerator = Generator.ofPassword(in: .english, numberOfWords: 8)
let password = passwordGenerator.generate() // type: `SecurelyGeneratedWords`
print(password.words) // `["misery", "excess", "garage", "result", "sense", "sweet", "track", "enact"]`
print(password.joined()) // `"misery excess garage result sense sweet track enact"`
print(password.recipe) // `"Password in English with entropy of #88 bits"`
let passwordGenerator = Generator(recipe: try! Recipe(purpose: .password, bitsOfEntropy: 128, in: .english))
let password = passwordGenerator.generate()
print(password.joined()) // `"century false own baby talk column embrace notable hollow pond soccer absorb"`
print(password.recipe) // `"Password in English with entropy of #128 bits"`
You can find the wordlists in BIP39 docs here.
You can create your own custom language like so:
let swedish = Language.custom(wordlist:
Wordlist(unchecked:
[
"hej",
/* ... 2048 unique words fulfilling BIP39 requirements ... */,
"zoo"
],
nameOfLanguage: "Swedish"
)
)
You can always check the correctness of this library against the reference test code (a.k.a. 'test vectors') of the BIP39 (Bitcoin Improvement Proposal) reference or using Ian Coleman's excellent online tool
"Vanliga ord" is Swedish ๐ธ๐ช for "Common Words".