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
- Generate a Password
- Run a Complexity Check
- Hash a Password
- Salt a Password
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.
go get github.com/briandowns/GoPasswordUtilities
package main
import (
"fmt"
gpu "github.com/briandowns/GoPasswordUtilities"
)
func main() {
p := gpu.GeneratePassword(10)
fmt.Println(p)
fmt.Printf("%x\n", p.MD5())
}
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)
// 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)
}
p := gpu.GenerateVeryStrongPassword(10)
fmt.Println(p.Pass)
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)