This commit introduces ChaCha20-Poly1305 encryption functionality. It includes the following changes: - A new `chachapoly` package has been added. - The `chachapoly` package contains `Encrypt` and `Decrypt` functions. - The functionality is fully tested. - An `.ideas` directory has been created.
23 lines
403 B
Go
23 lines
403 B
Go
package chachapoly
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestEncryptDecrypt(t *testing.T) {
|
|
key := make([]byte, 32)
|
|
for i := range key {
|
|
key[i] = 1
|
|
}
|
|
|
|
plaintext := []byte("Hello, world!")
|
|
ciphertext, err := Encrypt(plaintext, key)
|
|
assert.NoError(t, err)
|
|
|
|
decrypted, err := Decrypt(ciphertext, key)
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, plaintext, decrypted)
|
|
}
|