(data []byte, passphrase string)
| 46 | } |
| 47 | |
| 48 | func encrypt(data []byte, passphrase string) []byte { |
| 49 | block, _ := aes.NewCipher([]byte(createHash(passphrase))) |
| 50 | gcm, err := cipher.NewGCM(block) |
| 51 | if err != nil { |
| 52 | panic(err.Error()) |
| 53 | } |
| 54 | nonce := make([]byte, gcm.NonceSize()) |
| 55 | if _, err = io.ReadFull(rand.Reader, nonce); err != nil { |
| 56 | panic(err.Error()) |
| 57 | } |
| 58 | ciphertext := gcm.Seal(nonce, nonce, data, nil) |
| 59 | return ciphertext |
| 60 | } |
| 61 | |
| 62 | func decrypt(data []byte, passphrase string) []byte { |
| 63 | key := []byte(createHash(passphrase)) |
no test coverage detected