Last active
April 1, 2019 00:48
-
-
Save sle-c/ba05e2bad36424b0a35d2db6109f049b to your computer and use it in GitHub Desktop.
Create random key string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"crypto/rand" | |
) | |
func NewRandomKey() []byte { | |
key := make([]byte, 32) | |
if _, err := rand.Read(key); err != nil { | |
// really, what are you gonna do if randomness failed? | |
panic(err) | |
} | |
return key | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment