1
0
Fork 0
forked from External/ergo

review fixes

This commit is contained in:
Shivaram Lingamneni 2019-05-12 16:26:23 -04:00
parent 2451737f87
commit 11076be0ee
4 changed files with 18 additions and 2 deletions

View file

@ -7,6 +7,7 @@ import (
"crypto/rand"
"crypto/subtle"
"encoding/base32"
"encoding/base64"
)
var (
@ -37,3 +38,10 @@ func SecretTokensMatch(storedToken string, suppliedToken string) bool {
return subtle.ConstantTimeCompare([]byte(storedToken), []byte(suppliedToken)) == 1
}
// generate a 256-bit secret key that can be written into a config file
func GenerateSecretKey() string {
var buf [32]byte
rand.Read(buf[:])
return base64.RawURLEncoding.EncodeToString(buf[:])
}