https://github.com/8ff/diceware
Golang Diceware library and password generator
https://github.com/8ff/diceware
Last synced: 5 months ago
JSON representation
Golang Diceware library and password generator
- Host: GitHub
- URL: https://github.com/8ff/diceware
- Owner: 8ff
- License: agpl-3.0
- Created: 2023-03-04T22:19:18.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-11T02:14:39.000Z (about 1 year ago)
- Last Synced: 2025-03-11T02:29:57.261Z (about 1 year ago)
- Language: Go
- Size: 734 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# Diceware
[](https://goreportcard.com/report/github.com/8ff/diceware)
[](https://godoc.org/github.com/8ff/diceware)
[](https://raw.githubusercontent.com/8ff/diceware/master/LICENSE)
[](https://github.com/8ff/diceware/releases/latest)
Diceware is a technique for generating strong, memorable passwords using dice to select words from a list. The Diceware method is based on the idea that each word in the list corresponds to a unique combination of five dice rolls, making it difficult for attackers to guess the password.
## Diceware
The `diceware` library provided in this project allows you to generate diceware passwords using Go. The library includes functions for generating a list of words, a randomised list of words, and a map of words that corresponds to each possible combination of dice rolls.
### Example
```go
package main
import (
"fmt"
"github.com/8ff/diceware"
)
func main() {
// Get a slice of words
words := diceware.GetWords()
fmt.Println("Number of entries:", len(words))
// Get a randomised slice of words
randomWords := diceware.GetRandomWords()
fmt.Println("Number of entries in randomised list:", len(randomWords))
// Get a map of words
wordsMap := diceware.GetWordsMap()
fmt.Println("Number of entries in words map:", len(wordsMap))
}
```
## Pwgen
The `pwgen` tool located in cmd/pwgen provided in this project allows you to generate diceware passwords using the command line.

### Installing pwgen
```bash
repo="diceware"; name="pwgen"; os=$(uname | tr '[:upper:]' '[:lower:]'); arch=$(uname -m); case $arch in x86_64) arch="amd64" ;; arm64) arch="arm64" ;; esac; url="https://github.com/8ff/${repo}/releases/download/latest/${name}.${os}.${arch}"; curl -L $url -o ${name} && chmod +x ${name}
```
## Generating passwords
To generate a diceware password using the pwgen command-line tool, you can run the go run command followed by the path to the pwgen package and any options you want to use. By default, pwgen will generate a 6-word diceware password.
You can specify a different password length by using the -l or --length option followed by a number. For example, to generate a 10-word diceware password, you can run the following command:
```bash
cd cmd/pwgen
go run main.go -l 10
```
The resulting password will be printed to the console.