dicewarelib

package module
v0.0.0-...-9f7f857 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

README

go-dicewarelib

Contains a few basic functions that allow for diceware password generation, with sensible defaults that work with most websites.

This is v0.0.X software whose API may change at any time, and is not suitable for any serious production use. It's really just meant for my own reuse in other similar applications.

Setup

If you're going to use this in your application, you should download words-complex.txt and/or words-simple.txt depending on your needs. These are managed via git lfs.

Obtain it via go get:

go get git.cmcode.dev/cmcode/go-dicewarelib

Example

See ./example/main.go for this full example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePassword

func GeneratePassword(words *Words, n int, s string, maxLen int, minLen int, extendedWords bool) string

GeneratePassword generates a password according to a few rules:

w=dictionary of random words to choose from

n=number of words

s=separator character

maxLen=maximum allowable length of the resulting password

minLen=minimum allowable length of the resulting password.

func GetRandomInt

func GetRandomInt(m int) int

GetRandomInt generates a random number from 0 to m.

func GetWords

func GetWords(content embed.FS, path string) (map[int]string, int)

GetWords loads all words from the given path into memory. Note that the word list must be embedded, using embed.FS.

Types

type Words

type Words struct {
	Simple       *map[int]string
	SimpleCount  int
	Complex      *map[int]string
	ComplexCount int
}

Words stores all of the simple and/or complex words in memory. The number of words is calculated once and stored as well for later (frequent) use.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL