Rsa encryptor easy to use
To install rsa encryptor:
- Go to releses and download Encryptor.dll and Encryptor.xml for documentation 2. Move downloaded files to your project location
- Add Encryptor.dll reference to your project
- Add:
using Encryptor;
To get started you will have to create instance of your encryptor like this:
RsaEncryptor rsaEncryptorInstance = new RsaEncryptor(1024); //key lenght = 1024 bits
Note that you can use diferent key lenghts depending on preferences
To encrypt your data you just have to call function:
RSAParameters somePublicKey;
byte[] dataToEncrypt = Encoding.ASCII.GetBytes("test message");
byte[] encryptedData = rsaEncryptorInstance.encrypt(dataToEncrypt, somePublicKey);
You can also pass string as an argument:
byte[] encryptedData = rsaEncryptorInstance.encrypt("test message", somePublicKey);
Here is an example:
static RsaEncryptor rsaEncryptorInstance = new RsaEncryptor(1024);
static void Main(string[] args)
{
string encryptedData = Encoding.ASCII.GetString(rsaEncryptorInstance.encrypt("test message", rsaEncryptorInstance.GetPublicKey()));
Console.WriteLine(encryptedData);
}
Example output:
string output = "S??A?zA?↨?-↨?#*▲?§?>???▲NI?↕L\???.?A¶?K?/-?1?,????G??>?????F?g?O?▼??q♥:Hi?i??↨?????$?????8}cL9?5h??B↕???|2"
IMPORTANT NOTE: Please note that converting encrypted data to a string and then converting it back to byte array will break message and u won't be able to decrypt it! This was done only for demonstartion purpeses.
To decrypt some data call function:
byte[] encryptedData;
byte[] decryptedData = rsaEncryptorInstance.decrypt(encryptedData);
if you want to use other private key use:
RSAParameters somePrivateKey;
byte[] encryptedData;
byte[] decryptedData = rsaEncryptorInstance.decrypt(encryptedData, somePrivateKey);
To extract string from encrypted data use:
byte[] encryptedData;
string decryptedString = rsaEncryptorInstance.decryptString(encryptedData);
MIT license - do whatever you want