[C#|OpenSSL] RSA is causing me headaches
Hi, iam using an external library (OpenSSL.Crypto) to encrypt/decrypt files in my c# project.
I have to use RSA, but there is a lack of documentation, I tried to find an example but no way :nonod:
i tried by myself to explore the library and i wrote this code:
Have any one used RSA before with this library?
Re: [C#|OpenSSL] RSA is causing me headaches
This is how you create a RSA key pair and use it to encrypt/decrypt a byte:
// Generate key pair
var rsa = new RSA();
rsa.GenerateKeys(2048, 0x10021, null, null);
// Encrypt file
byte payLoad = File.ReadAllBytes("c:\folder\myfile.ext");
byte encryptedResult = rsa.PublicEncrypt(payload, RSA.Padding.PKCS1);
// Decrypt file
byte decryptedResult = rsa.PrivateDecrypt(encryptedResult, RSA.Padding.PKCS1);
Hope this helps!
|All times are GMT +5.5. The time now is 22:05.|