Password hashing package compatible with Node's password-hash
package main
import "github.com/malixsys/passwordHash"
func main() {
// Generate a hashed password
testPassword := `test1234`
hashedPassword := passwordHash.Generate(testPassword, nil)
// Test correct password in constant time
valid := passwordHash.Verify(hashedPassword, testPassword)
log.Printf("The password validity is %t against the hash", valid)
// Test incorrect password in constant time
valid, err = passwordHash.Verify(hashedPassword, "badPass")
log.Printf("The password validity is %t against the hash", valid)
}
Some tests are included
To run, use:
go test
- Extend to other algorithms
- More development info
- More tests
- Used in Node project: password-hash
- Package layout inspiration: argon2pw