1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
package spectre
import "golang.org/x/crypto/scrypt"
func userKey(name, secret string, scoper Scoper) ([]byte, error) {
nameBytes := []byte(name)
secretBytes := []byte(secret)
keyScope := []byte(scoper.Scope(Authentication))
nameBytesLen := len(nameBytes)
keySalt := append(keyScope, bigEndian(nameBytesLen)...)
keySalt = append(keySalt, nameBytes...)
return scrypt.Key(secretBytes, keySalt, 32768, 8, 2, 64)
}
|