Diceware passphrases in go. - by Lukas Malkmus
Package diceware is a simple implementation of the
diceware passphrase generation method.
Instead of using the normal wordlists, it uses the computer-optimized
diceword8k list.
Furhtermore it utilizes go's crypto/rand
library to generate true random
passphrases.
Be advised, that the prefered way of generating diceware passphrases is to do it the old-school way by actually throwing real dices by hand. This is the only 100% secure way.
- Simple API
- Only go standard library
- Passphrases with choosable length
- Diceware extras for stronger passphrases
- Verify passphrases
- Multiple word lists in multiple languages
- Read word list from file/buffer (
io.Reader
)
Please use a dependency manager like glide to make sure you use a tagged release.
Install using go get
:
go get -u -v github.com/lukasmalkmus/diceware
Create a passphrase with default values (6 words, no extra):
p, err := diceware.NewPassphrase()
if err != nil {
// ...
}
fmt.Println(p)
It is also possible to create a passphrase with more or less words. Please note that 6 words is a sensitiv default and less isn't recommended!
p, err := diceware.NewPassphrase(
diceware.Words(7), // Passphrase with 7 words
)
if err != nil {
// ...
}
fmt.Println(p)
Note! If you want to use less than 6 words, be sure to set the Validate
option
to false
! Otherwise validation will fail!
All passphrases can be regenerated. This means the options you applied in the
NewPassphrase()
function are reused for the passphrase generation.
p.Regenerate()
fmt.Println(p)
- Passphrase implements the Stringer interface thus it can be passed to every
function accepting this interface. For example
fmt.Println()
. - The
String()
method isn't very "human friendly". Use theHumanize()
method to print the passphrase with whitspace seperated words. - Passphrase strength can be improved by adding an extra. Do this by setting the
Extra option:
Extra(true)
Feel free to submit PRs or to fill Issues. Every kind of help is appreciated.
© Lukas Malkmus, 2017
Distributed under MIT License (The MIT License
).
See LICENSE for more information.