mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-03-30 05:18:47 +02:00
19 lines
466 B
Go
19 lines
466 B
Go
package util
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
)
|
|
|
|
// MakeSignature generates a cryptographically-secure pseudo-random token, based on a given number of random bytes, for signing purposes.
|
|
func MakeSignature(size int) ([]byte, error) {
|
|
b := make([]byte, size)
|
|
_, err := rand.Read(b)
|
|
if err != nil {
|
|
b = nil
|
|
}
|
|
// base64 encode it so signing key can be typed into validation utilities
|
|
b = []byte(base64.StdEncoding.EncodeToString(b))
|
|
return b, err
|
|
}
|