1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00
Files
lancet/cryptor/rsa_test.go
2021-11-28 21:28:23 +08:00

20 lines
468 B
Go

package cryptor
import (
"testing"
"github.com/duke-git/lancet/utils"
)
func TestRsaEncrypt(t *testing.T) {
GenerateRsaKey(4096, "rsa_private.pem", "rsa_public.pem")
data := []byte("hello world")
encrypted := RsaEncrypt(data, "rsa_public.pem")
decrypted := RsaDecrypt(encrypted, "rsa_private.pem")
if string(data) != string(decrypted) {
utils.LogFailedTestInfo(t, "RsaEncrypt/RsaDecrypt", string(data), string(data), string(decrypted))
t.FailNow()
}
}