Skip to content

Golang library for generating passphrases via the diceware algorithm.

License

Notifications You must be signed in to change notification settings

sethvargo/go-diceware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Golang Diceware Generator

GoDoc GitHub Actions

This library implements the Diceware algorithm in pure Golang. The algorithm is most-commonly used when generating human-readable passwords. You may be familiar with the XKCD comic.

The list of words are generated from the EFF's "long" list. However, the API's are abstracted so you can roll die and then use your own word list as-needed.

It uses crypto/rand for rolling die for added randomness.

Sample example words this library may choose:

squirt catchy anatomy storm
patchy replica scholar alkalize
operative shrank lying uncorrupt
confusion studio abstain subdivide chewy ouch password tropical pentagon

Installation

$ go get -u github.com/sethvargo/go-diceware/diceware/...

Usage

package main

import (
  "log"
  "strings"

  "github.com/sethvargo/go-diceware/diceware"
)

func main() {
  // Generate 6 words using the diceware algorithm.
  list, err := diceware.Generate(6)
  if err != nil  {
    log.Fatal(err)
  }
  log.Printf(strings.Join(list, "-"))
}

See the GoDoc for more information.

CLI

As a CLI:

$ GO111MODULE=off go get github.com/sethvargo/go-diceware/cmd/diceware
$ diceware -h

License

This code is licensed under the MIT license.