(data []byte, key []byte)
| 24 | } |
| 25 | nonce := make([]byte, gcm.NonceSize()) |
| 26 | if _, err := rand.Read(nonce); err != nil { |
| 27 | return nil, err |
| 28 | } |
| 29 | return gcm.Seal(nonce, nonce, data, nil), nil |
| 30 | } |
| 31 | |
| 32 | func decrypt(data []byte, key []byte) ([]byte, error) { |
| 33 | gcm, err := newGCM(key) |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | nonceSize := gcm.NonceSize() |
| 38 | if len(data) < nonceSize { |
| 39 | return nil, errCiphertextTooShort |
| 40 | } |
no test coverage detected