mirror of
https://github.com/empayre/fleet.git
synced 2024-11-08 09:43:51 +00:00
29570bd860
* Add leader selection * remove comment * Address review comments * Add changes file * Simplify implementation * Simplify further * Whoops, removed a little too much
18 lines
397 B
Go
18 lines
397 B
Go
package server
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
)
|
|
|
|
// GenerateRandomText return a string generated by filling in keySize bytes with
|
|
// random data and then base64 encoding those bytes
|
|
func GenerateRandomText(keySize int) (string, error) {
|
|
key := make([]byte, keySize)
|
|
_, err := rand.Read(key)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return base64.StdEncoding.EncodeToString(key), nil
|
|
}
|