mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
21 lines
455 B
Go
21 lines
455 B
Go
package cryptor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/duke-git/lancet/v2/internal"
|
|
)
|
|
|
|
func TestRsaEncrypt(t *testing.T) {
|
|
err := GenerateRsaKey(4096, "rsa_private.pem", "rsa_public.pem")
|
|
if err != nil {
|
|
t.FailNow()
|
|
}
|
|
data := []byte("hello world")
|
|
encrypted := RsaEncrypt(data, "rsa_public.pem")
|
|
decrypted := RsaDecrypt(encrypted, "rsa_private.pem")
|
|
|
|
assert := internal.NewAssert(t, "TestRsaEncrypt")
|
|
assert.Equal(string(data), string(decrypted))
|
|
}
|