Giter Site home page Giter Site logo

genpass's Introduction


๐Ÿ”ข genPass ๐Ÿ”ฃ

Simple and straight-forward random password generator in Go, offering simple but useful options for how the final password will look like.

Currently we support the following usecases:

  • Numeric passwords
  • Alphabetic passwords
  • Alphanumeric passwords
  • Alphanumeric with symbols (~!@#$%^&*()_-+?)

Sample of generated passwords (using default length with various charset and case options options):

93376358    xnzrowlk    34weaqb0
0oc7lm7?    146EQGAQ    ye7OjZmz

Please note that currently we do not support "fancy stuff" like entropy control at the moment, leaving it entirely in control of Go's crypto/rand package.

Examples:

import (
	"fmt"

	"github.com/streppel/genpass"
)

func main() {
	// default password length is 8
	// default password is numeric
	numericPass := genpass.NewPassword()
	fmt.Println(numericPass) // example: "34997406"

	// control password len with .WithLength
	tinyPass := genpass.NewPassword(genpass.WithLength(3))
	fmt.Println(tinyPass) // example: "531"

	// to generate an alphabetic password, use Alphabetic option
	alphabeticPass := genpass.NewPassword(genpass.WithCharacters(genpass.Alphabetic))
	fmt.Println(alphabeticPass) // example: "pduhkuyu"

	// so on with alphanumeric, or with symbols
	alphanumericPass := genpass.NewPassword(
		genpass.WithCharacters(genpass.Alphanumeric))
	symbolsPass := genpass.NewPassword(
		genpass.WithCharacters(genpass.AlphanumericWithSymbols))
	fmt.Println(alphanumericPass) // example: "7bvimig3"
	fmt.Println(symbolsPass) // example: "~sa&&*_c"

	// when using alpha characters, we can also modify the type case (default is lower)
	alphaUpperPass := genpass.NewPassword(
		genpass.WithCharacters(genpass.Alphanumeric),
		genpass.WithCase(genpass.Uppercase))
	alphanumericMixedPass := genpass.NewPassword(
		genpass.WithCharacters(genpass.Alphanumeric),
		genpass.WithCase(genpass.Mixedcase))
	fmt.Println(alphaUpperPass) // example: "I4U1ZHIV"
	fmt.Println(alphanumericMixedPass) // example: "6YTNzu2w"
}

Benchmarking with default password generation:

goos: linux
goarch: amd64
pkg: github.com/streppel/genpass
BenchmarkNewPassword-8           1819519               653 ns/op
PASS

genpass's People

Contributors

streppel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.