NewCipher — key must be 16, 24, or 32 bytes
key := make([]byte, 32) // AES-256
rand.Read(key)
block, err := aes.NewCipher(key)
if err != nil { log.Fatal(err) }
crypto/aesThe AES block cipher. Creates a cipher.Block you combine with a mode from crypto/cipher (GCM, CBC, CTR). Never use AES-ECB.
key := make([]byte, 32) // AES-256
rand.Read(key)
block, err := aes.NewCipher(key)
if err != nil { log.Fatal(err) }
Use AES-GCM (via crypto/cipher.NewGCM) unless you have an unusual reason not to. See the crypto/cipher page for the full example.