go-password

module
v0.0.0-...-fd4fc0b Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT

README

Golang Password Generation Library

Build Status GoDoc

Performance-oriented library for the generation of random passwords.

Inspired by Seth Vargos go-password implementation.

Installation

$ go get -u github.com/szybia/go-password/password

cli tool for generating passwords:

$ go get -u github.com/szybia/go-password/randpw

Usage

package main

import (
	"fmt"

	"github.com/szybia/go-password/password"
)

func main() {
	//	Generate a random password of length 50
	pass, err := password.GenerateLength(50)
	if err != nil {
		panic(err)
	}
	fmt.Println(pass)
}

Output:

Rg,FCu/4{'(ZWB4HR5D~%R[vA{ITM^!i5\{pkq;VnIj?=O"CL3

You can also create your own generators with a specific character set as shown below:

//	Create generator with specified character set
g := password.NewGenerator(&password.CharSet{
	Lowercase: "abc",
	Uppercase: "ABC",
	Digits:    "012",
	Symbols:   "",
})

//	Generate a password consisting of
//	5 lowercase, uppercase letters and 5 digits
pass, err := g.Generate(5, 5, 5, 0) //  output: 1Cc1c02cAB2CBba

//  Generate a password of length 15
pass, err := g.GenerateLength(15)   //  output: a0BC1B1cbA1a10B

Directories

Path Synopsis
Package password provides a library for generating random passwords using the crypto/rand package.
Package password provides a library for generating random passwords using the crypto/rand package.
cmd

Jump to

Keyboard shortcuts

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