15 lines
202 B
Go
15 lines
202 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"crypto/rand"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
func GenerateRandomKey(length int) []byte {
|
||
|
k := make([]byte, length)
|
||
|
if _, err := io.ReadFull(rand.Reader, k); err != nil {
|
||
|
return nil
|
||
|
}
|
||
|
return k
|
||
|
}
|