Files
Gogs/internal/cryptox/aes_test.go
ᴊᴏᴇ ᴄʜᴇɴ 36d56d5525 all: rename packages ending with "util" to end with "x" (#8182)
Co-authored-by: JSS <jss@unknwon.dev>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 13:25:19 -05:00

31 lines
483 B
Go

package cryptox
import (
"crypto/rand"
"testing"
"github.com/stretchr/testify/assert"
)
func TestAESGCM(t *testing.T) {
key := make([]byte, 16) // AES-128
_, err := rand.Read(key)
if err != nil {
t.Fatal(err)
}
plaintext := []byte("this will be encrypted")
encrypted, err := AESGCMEncrypt(key, plaintext)
if err != nil {
t.Fatal(err)
}
decrypted, err := AESGCMDecrypt(key, encrypted)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, plaintext, decrypted)
}