mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
20 lines
468 B
Go
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()
|
|
}
|
|
}
|