pwgen

package
v1.12.9 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package pwgen implements multiple popular password generate algorithms. It supports creating classic cryptic passwords with different character classes as well as more recent memorable approaches.

Some methods try to ensure certain requirements are met and can be very slow.

Index

Examples

Constants

View Source
const (
	Digits = "0123456789"
	Upper  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Lower  = "abcdefghijklmnopqrstuvwxyz"
	Syms   = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
	Ambiq  = "0ODQ1IlB8G6S5Z2"
	// CharAlpha is the class of letters
	CharAlpha = Upper + Lower
	// CharAlphaNum is the class of alpha-numeric characters
	CharAlphaNum = Digits + Upper + Lower
	// CharAll is the class of all characters
	CharAll = Digits + Upper + Lower + Syms
)

Character classes

Variables

This section is empty.

Functions

func GenerateExternal added in v1.12.9

func GenerateExternal(pwlen int) (string, error)

GenerateExternal will invoke an external password generator, if set, and return it's output.

func GenerateMemorablePassword added in v1.12.9

func GenerateMemorablePassword(minLength int, symbols bool, capitals bool) string

GenerateMemorablePassword will generate a memorable password with a minimum length

Example
fmt.Println(GenerateMemorablePassword(12, false, false))
Output:

func GeneratePassword

func GeneratePassword(length int, symbols bool) string

GeneratePassword generates a random, hard to remember password

func GeneratePasswordCharset

func GeneratePasswordCharset(length int, chars string) string

GeneratePasswordCharset generates a random password from a given set of characters

func GeneratePasswordCharsetCheck

func GeneratePasswordCharsetCheck(length int, chars string) string

GeneratePasswordCharsetCheck generates a random password from a given set of characters and validates the generated password with crunchy

func GeneratePasswordWithAllClasses added in v1.8.0

func GeneratePasswordWithAllClasses(length int, symbols bool) (string, error)

GeneratePasswordWithAllClasses tries to enforce a password which contains all character classes instead of only enabling them. This is especially useful for broken (corporate) password policies that mandate the use of certain character classes for no good reason

func Prune added in v1.12.9

func Prune(in string, cutset string) string

Prune removes all characters in cutset from the input

Types

type Cryptic added in v1.12.9

type Cryptic struct {
	Chars      string
	Length     int
	MaxTries   int
	Validators []func(string) error
}

Cryptic is a generator for hard-to-remember passwords as required by (too) many sites. Prefer memorable or xkcd-style passwords, if possible.

func NewCryptic added in v1.12.9

func NewCryptic(length int, symbols bool) *Cryptic

NewCryptic creates a new generator with sane defaults.

func NewCrypticForDomain added in v1.12.9

func NewCrypticForDomain(length int, domain string) *Cryptic

NewCrypticForDomain tries to look up password rules for the given domain or uses the default generator.

func NewCrypticWithAllClasses added in v1.12.9

func NewCrypticWithAllClasses(length int, symbols bool) *Cryptic

NewCrypticWithAllClasses returns a password generator that generates passwords containing all available character classes

func NewCrypticWithCrunchy added in v1.12.9

func NewCrypticWithCrunchy(length int, symbols bool) *Cryptic

NewCrypticWithCrunchy returns a password generators that only returns a password if it's successfully validated with crunchy.

func (*Cryptic) Password added in v1.12.9

func (c *Cryptic) Password() string

Password returns a single password from the generator

Directories

Path Synopsis
Code generated by go generate gen.go.
Code generated by go generate gen.go.

Jump to

Keyboard shortcuts

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