Skip to content

Instantly share code, notes, and snippets.

@sle-c
Last active April 1, 2019 00:48
Show Gist options
  • Save sle-c/ba05e2bad36424b0a35d2db6109f049b to your computer and use it in GitHub Desktop.
Save sle-c/ba05e2bad36424b0a35d2db6109f049b to your computer and use it in GitHub Desktop.
Create random key string
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