Go package to facilitate the use of the Argon2id password hashing algorithm from the "crypto/argon2" package.
go get "github.com/KEINOS/go-argonize"
func Example() {
// Your strong and unpredictable password
password := []byte("my password")
// Password hash your password
hashedObj, err := argonize.Hash(password)
if err != nil {
log.Fatal(err)
}
// View the hashed password
fmt.Println("Passwd to save:", hashedObj.String())
// Verify password (golden case)
if hashedObj.IsValidPassword([]byte("my password")) {
fmt.Println("the password is valid")
} else {
fmt.Println("the password is invalid")
}
// Verify password (wrong case)
if hashedObj.IsValidPassword([]byte("wrong password")) {
fmt.Println("the password is valid")
} else {
fmt.Println("the password is invalid")
}
// Output:
// Passwd to save: $argon2id$v=19$m=65536,t=1,p=2$ek6ZYdlRm2D5AsGV98TWKA$QAIDZEdIgwohrNX678mHc448LOmD7jGR4BGw/9YMMVU
// the password is valid
// the password is invalid
}
- View more examples and advanced usages @ pkg.go.dev
Any Pull-Request for improvement is welcome!
- Branch to PR:
main
-
CIs on PR/Push:
-
unit-tests
- Inclues compatibility tests against PHP, Python and C implementations
- golangci-lint
-
platform-tests
- Tests on Win, macOS and Linux
- codeQL-analysis
-
unit-tests
- Our Security Policy
- MIT, Copyright (c) 2022 KEINOS and the go-Argonize contributors.
- This Go package is strongly influenced by an article by Alex Edwards.