mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
16 lines
306 B
Go
16 lines
306 B
Go
|
package raw
|
||
|
|
||
|
import (
|
||
|
"golang.org/x/crypto/pbkdf2"
|
||
|
"hash"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
MinRounds = 1
|
||
|
MaxRounds = 0xffffffff // setting at 32-bit limit for now
|
||
|
)
|
||
|
|
||
|
func Hash(password, salt []byte, rounds int, hf func() hash.Hash) (hash string) {
|
||
|
return Base64Encode(pbkdf2.Key(password, salt, rounds, hf().Size(), hf))
|
||
|
}
|