Swiftpack.co - Sajjon/VanligaOrd as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Sajjon.
Sajjon/VanligaOrd 0.0.1
A minimal BIP39 compatible library for generation of common words as password or BIP39 mnemonic.
โญ๏ธ 4
๐Ÿ•“ 3 years ago
iOS macOS
.package(url: "https://github.com/Sajjon/VanligaOrd.git", from: "0.0.1")

Be Safe ๐Ÿ›ก

Generate passwords that are

๐Ÿ”๐Ÿ’ช Cryptographically secure

๐Ÿง ๐Ÿ’ก Easy to remember

A minimal BIP39 compatible library for generation of common words as password or BIP39 mnemonic.

Xkcd 936

Generate Now

git clone --depth 1 [email protected]:Sajjon/VanligaOrd.git && cd VanligaOrd && sh generate.sh

Recommended Strength

Reddit user HelmedHorror has created this amazing table about password strength.

Reddit

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.

Required word count

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

Run in terminal (CLI support)

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

Installation

Installable via Swift Package Manager (SPM):

Xcode 11

From Xcode 11, you can use SPM to add VanligaOrd to your project:

  1. Select File > Swift Packages > Add Package Dependency, Enter https://github.com/Sajjon/VanligaOrd.git in the "Choose Package Repository" dialog.
  2. In the next page, specify the version resolving rule as "Up to Next Major" with "0.0.1" as its earliest version.
  3. 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 -

Package.swift file

Add in your Package.swift file

dependencies: [
    .package(url: "https://github.com/Sajjon/VanligaOrd", from: "0.0.1"),
],

Usage

All BIP39 languages are supported, which are:

  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese (simplified and traditional)
  • ๐Ÿ‡จ๐Ÿ‡ฟ Czech
  • ๐Ÿ‡ฌ๐Ÿ‡ง English
  • ๐Ÿ‡ซ๐Ÿ‡ท French
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian
  • ๐Ÿ‡ฏ๐Ÿ‡ต Japanese
  • ๐Ÿ‡ฐ๐Ÿ‡ท Korean.
  • ๐Ÿ‡ช๐Ÿ‡ธ Spanish

BIP39 Mnemonic

Support coming soon, stay tuned ๐Ÿ“ฃ.

Passwords

By word count

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"`

By entropy

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"`

Wordlist

You can find the wordlists in BIP39 docs here.

Custom Language

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"
    )
)

Reference

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

Etymology

"Vanliga ord" is Swedish ๐Ÿ‡ธ๐Ÿ‡ช for "Common Words".

GitHub

link
Stars: 4
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics