Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncryptPassword ¶
EncryptPassword encrypt password, pbkdf2, salt = uuid, with 4096 iterations, keyLen= 32, sha256
Example ¶
ExampleEncryptPassword hashes a password with a per-user salt. Store the salt next to the hash; to check a login, hash the entered password with the same salt and compare the two strings.
package main
import (
"fmt"
"github.com/phcp-tech/common-library-golang/encrypt"
)
func main() {
stored := encrypt.EncryptPassword("password", "salt")
fmt.Println(stored)
fmt.Println(encrypt.EncryptPassword("password", "salt") == stored)
fmt.Println(encrypt.EncryptPassword("wrong", "salt") == stored)
}
Output: xeR41ZKIyEGqUw22hFxMjZYok6ABzk4RpJY4c6qYE0o= true false
Types ¶
This section is empty.