Skip to content

briandowns/GoPasswordUtilities

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoPasswordUtilities

GoDoc Build Status

Simple library for working with passwords in Go (Golang).

Complexity check will check for upper case letters, lower case letters, numbers, special characters and also whether the password is dictionary based.

For more detail about the library and its features, reference your local godoc once installed.

godoc -http=:6060

Features

  • Generate a Password
  • Run a Complexity Check
  • Hash a Password
  • Salt a Password

Warning

This library is in alpha and will be subject to change. Use with caution. There's also a damn good chance it could be in a broken state at times as well.

Installation

go get github.com/briandowns/GoPasswordUtilities

Examples

Import the package, generate a password and hash it.

package main

import (
	"fmt"
	gpu "github.com/briandowns/GoPasswordUtilities"
)

func main() {
	p := gpu.GeneratePassword(10)
	fmt.Println(p)
	fmt.Printf("%x\n", p.MD5())
}

Create a new password object and get its information

    pass := gpu.New("secret12")
    fmt.Println(*pass)
    
    results, err := gpu.ProcessPassword(pass)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Printf("Has Rating: %s\n", results.ComplexityRating())
    fmt.Printf("%t\n", results.DictionaryBased)

Generate thousands of passwords.

    // On the fly compile and execution.  Better 
    ///once statically compiled.
    // 0.19s user 0.07s system 84% cpu 0.303 total
    passChan := make(chan *gpu.Password, 10000)
    go func() {
        for i := 0; i < 10000; i++ {
            passChan <- gpu.GeneratePassword(8)
        }
        close(passChan)
    }()

    for pass := range passChan {
        fmt.Printf("%s\n", pass.Pass)
    }

Generate a Very Strong password.

    p := gpu.GenerateVeryStrongPassword(10)
    fmt.Println(p.Pass)

Hash a password that includes a generated salt.

    p := gpu.GeneratePassword(10)
    fmt.Println(p.Pass)
    hash1, _ := p.SHA256()
    hash2, salt := p.SHA256(&gpu.SaltConf{Length: 32})
    fmt.Printf("%x\n", hash1)
    fmt.Printf("%x - %x\n", hash2, salt)   

About

Simple library for working with passwords in Go (golang).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages