forked from External/ergo
review fixes
This commit is contained in:
parent
2451737f87
commit
11076be0ee
4 changed files with 18 additions and 2 deletions
|
|
@ -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[:])
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue