26 lines
397 B
Go
26 lines
397 B
Go
|
package pfug
|
||
|
|
||
|
import (
|
||
|
"encoding/base64"
|
||
|
|
||
|
"golang.org/x/crypto/argon2"
|
||
|
)
|
||
|
|
||
|
func generatePasswordHash(password string, salt string) string {
|
||
|
const time uint32 = 4
|
||
|
const threads uint8 = 4
|
||
|
const memory uint32 = 64 * 1024
|
||
|
const keyLen uint32 = 32
|
||
|
|
||
|
dk := argon2.IDKey(
|
||
|
[]byte(password),
|
||
|
[]byte(salt),
|
||
|
time,
|
||
|
memory,
|
||
|
threads,
|
||
|
keyLen,
|
||
|
)
|
||
|
|
||
|
return base64.StdEncoding.EncodeToString(dk)
|
||
|
}
|