feat: add GenerateRsaKeyPair, RsaEncryptOAEP, RsaDecryptOAEP

This commit is contained in:
dudaodong committed 2023-09-14 14:06:54 +08:00
1 parent f445ecbaf8
commit 8ff37f0eff
3 files changed
+73 -1

No files matched your search

+18
View File
@@ -150,3 +150,21 @@ func TestRsaEncrypt(t *testing.T) {
assert := internal.NewAssert(t, "TestRsaEncrypt")
assert.Equal(string(data), string(decrypted))
}
func TestRsaEncryptOAEP(t *testing.T) {
assert := internal.NewAssert(t, "TestRsaEncrypt")
t.Parallel()
pri, pub := GenerateRsaKeyPair(1024)
data := []byte("hello world")
label := []byte("123456")
encrypted, err := RsaEncryptOAEP(data, label, *pub)
assert.IsNil(err)
decrypted, err := RsaDecryptOAEP([]byte(encrypted), label, *pri)
assert.IsNil(err)
assert.Equal("hello world", string(decrypted))
}