We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5413abc commit 2cb9e7fCopy full SHA for 2cb9e7f
src/crypto/cipher/example_test.go
@@ -29,14 +29,14 @@ func ExampleNewGCM_encrypt() {
29
panic(err.Error())
30
}
31
32
- // Never use more than 2^32 random nonces with a given key because of the risk of a repeat.
33
- nonce := make([]byte, 12)
34
- if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
+ aesgcm, err := cipher.NewGCM(block)
+ if err != nil {
35
36
37
38
- aesgcm, err := cipher.NewGCM(block)
39
- if err != nil {
+ // Never use more than 2^32 random nonces with a given key because of the risk of a repeat.
+ nonce := make([]byte, aesgcm.NonceSize())
+ if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
40
41
42
0 commit comments