feat: add AesGcmEncrypt and AesGcmDecrypt in cryptor package

This commit is contained in:
dudaodong committed 2024-09-10 10:37:47 +08:00
1 parent ba75e58e5f
commit c745097749
5 files changed
+232

No files matched your search

+14
View File
@@ -168,3 +168,17 @@ func TestRsaEncryptOAEP(t *testing.T) {
assert.IsNil(err)
assert.Equal("hello world", string(decrypted))
}
func TestAesGcmEncrypt(t *testing.T) {
t.Parallel()
data := "hello world"
key := "abcdefghijklmnop"
encrypted := AesGcmEncrypt([]byte(data), []byte(key))
decrypted := AesGcmDecrypt(encrypted, []byte(key))
assert := internal.NewAssert(t, "TestAesGcmEncrypt")
assert.Equal(data, string(decrypted))
}