简体   繁体   中英

use RSA encrypt/decrypt for client/server side on unity and node js

i working on a Online game with Unity and Node JS.

i used Node-RSA in my node js (server side) for Encrypt and Decrypt messages. i create public key and private key in hear now i have this two keys on server.

now i want to make same keys in C# (unity) for Decrypt messages and Encrypt message for send to server. in c# i used

RSACryptoServiceProvider

create this two RSAParameters

private RSAParameters PrivateKey;
private RSAParameters PublickKey;

but i don't now how can i change key value in them an put my server keys into them.

try it in node js

 const NodeRSA   = require('node-rsa');
 const key       = new NodeRSA('-----BEGIN RSA PRIVATE KEY-----PRIVATE_key----- 
 END RSA PRIVATE KEY-----");
 const text = 'helo';
 const encrypted = key.encrypt(text, 'base64');
 console.log('encrypted: ', encrypted);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM