v/vlib/crypto/rsa/rsa_test.v

26 lines
387 B
V
Raw Normal View History

2022-01-30 19:10:42 +01:00
import crypto.rsa
fn test_rsa() {
instance := rsa.gen_key_pair(1024, 3) or {
eprintln(err)
assert false
return
}
message := 'abc123456'
encrypted, len := instance.encrypt(message.bytes()) or {
eprintln(err)
assert false
return
}
decrypted := instance.decrypt(len, encrypted) or {
eprintln(err)
assert false
return
}
assert message == decrypted.bytestr()
}