I am using this library for sessions.
https://github.com/codegangsta/martini-contrib/tree/master/sessions
It says that:
It is recommended to use an authentication key with 32 or 64 bytes. The encryption key, if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
How do I generate a 64 byte key, is it as straightforward as []byte"64characterslongstring"
, I thought it is not always so straight forward?
To generate a slice of 64 random bytes:
package main
import "crypto/rand"
func main() {
key := make([]byte, 64)
_, err := rand.Read(key)
if err != nil {
// handle error here
}
}
Demo here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With