Skip to content

SuNNjek/identity

Repository files navigation

identity

CI status GoDoc

Go library implementing the ASP.NET Core identity password hashing algorithm

Install

go get -u github.com/SuNNjek/identity

Usage

Generate new password

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)

    // ...
}

Verify existing password hash

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))

    // ...
}

About

Go library implementing the ASP.NET Core identity password hashing algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages