Files
Gogs/internal/cryptoutil/aes_test.go
ᴊᴏᴇ ᴄʜᴇɴ 59e9fa191b chore: remove all MIT license file headers (#8083)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2026-01-08 19:32:15 -05:00

31 lines
486 B
Go

package cryptoutil
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)
}