Go library implementing the ASP.NET Core identity password hashing algorithm
go get -u github.com/SuNNjek/identity
package example
import (
"github.com/SuNNjek/identity"
)
func main() {
password := "my password"
// Generate new random salt
salt, _ := identity.GenerateSalt(identity.DefaultSaltLength)
// Hash the password using the default parameters
hash := identity.HashPasswordV3(
[]byte(password),
salt,
identity.DefaultHashAlgorithm,
identity.DefaultIterations,
identity.DefaultNumBytes)
// ...
}
package example
import (
"github.com/SuNNjek/identity"
)
func main() {
// Placeholder, replace with your logic to retrieve password hash
hashedPassword := getPasswordHash()
enteredPassword := "my password"
// Verify the entered password against the hashed one
passwordsMatch := identity.Verify(hashedPassword, []byte(enteredPassword))
// ...
}