Skip to content

Go package which provides an implementation of diceware passphrases.

License

Notifications You must be signed in to change notification settings

lukasmalkmus/diceware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lukasmalkmus/diceware

Diceware passphrases in go. - by Lukas Malkmus

Travis Status Coverage Status Go Report GoDoc Latest Release License


Table of Contents

  1. Introduction
  2. Features
  3. Usage
  4. Contributing
  5. License

Introduction

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.

Features

  • Simple API
  • Only go standard library
  • Passphrases with choosable length
  • Diceware extras for stronger passphrases
  • Verify passphrases

Todo

  • Multiple word lists in multiple languages
  • Read word list from file/buffer (io.Reader)

Usage

Installation

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

Creation

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!

Regeneration

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)

Tips & Tricks

  • 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 the Humanize() 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)

Contributing

Feel free to submit PRs or to fill Issues. Every kind of help is appreciated.

License

© Lukas Malkmus, 2017

Distributed under MIT License (The MIT License).

See LICENSE for more information.