passgen

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 3 Imported by: 0

README

Password Generator

Digits       standard.Template = "0123456789"
LowerLetters standard.Template = "abcdefghijklmnopqrstuvwxyz"
UpperLetters standard.Template = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Special      standard.Template = "~`!@#$%^&*()-+={}[]."
defaultStandard := standard.CreateStandard(20,
    examples.Digits, examples.LowerLetters, examples.UpperLetters, examples.Special)
password, _ := generator.Generate(defaultStandard)
type Standard interface {
	GetTemplate() string
	GetLength() uint
}

func Generate(standard Standard) string {
	template := standard.GetTemplate()

	password := make([]byte, standard.GetLength())
	for i := range password {
		index := rand.Int() % len(template)
		password[i] = template[index]
	}

	return string(password)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyTemplate = errors.New("empty template")
	ErrZeroLength    = errors.New("zero password length")
)

Functions

func Generate

func Generate(standard Standard) (string, error)

Types

type Standard

type Standard interface {
	GetTemplate() string
	GetLength() uint
}

Directories

Path Synopsis
cmd
cli command

Jump to

Keyboard shortcuts

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