EasyEncrypt.RSA
1.0.1.2
dotnet add package EasyEncrypt.RSA --version 1.0.1.2
NuGet\Install-Package EasyEncrypt.RSA -Version 1.0.1.2
<PackageReference Include="EasyEncrypt.RSA" Version="1.0.1.2" />
paket add EasyEncrypt.RSA --version 1.0.1.2
#r "nuget: EasyEncrypt.RSA, 1.0.1.2"
// Install EasyEncrypt.RSA as a Cake Addin #addin nuget:?package=EasyEncrypt.RSA&version=1.0.1.2 // Install EasyEncrypt.RSA as a Cake Tool #tool nuget:?package=EasyEncrypt.RSA&version=1.0.1.2
Welcome to the EasyEncrypt wiki!
First download the nuget package and add the namespace "EasyEncrypt".
Getting started
Example of encrypting a string or byte[] with Aes encryption:
string encryptedString = new Encryption(Aes.Create(), Password, Salt).Encrypt(Input);//1
string encryptedString = new Encryption(Aes.Create(), Keysize, Password, Salt).Encrypt(Input);//2
byte[] encryptedByteArray = new Encryption(Aes.Create(), Password, Salt).Encrypt(Input);//3
byte[] encryptedByteArray = new Encryption(Aes.Create(), Keysize, Password, Salt).Encrypt(Input);//4
//Only avaible for a string.
string EncryptedString = new Encryption(Aes.Create(), Password, Salt).Encrypt(Input, Encoding.Unicode);//5
Password is the password used to create the key.
Salt is used for making the generated key more random.
Keysize is the size of the key in bits. Example 1 detects the best keysize for the passed algorithm. In example 5 we use Unicode for decoding the string instead of UTF8(Default).
Example of decrypting a string or byte[] with Aes encryption:
string decryptedString = new Encryption(Aes.Create(), Password, Salt).Decrypt(EncryptedInput);//1
string decryptedString = new Encryption(Aes.Create(), Keysize, Password, Salt).Decrypt(EncryptedInput);//2
byte[] decryptedString = new Encryption(Aes.Create(), Password, Salt).Decrypt(EncryptedInput);//3
byte[] decryptedString = new Encryption(Aes.Create(), Keysize, Password, Salt).Decrypt(EncryptedInput);//4
//Only avaible for a string.
string decryptedString = new Encryption(Aes.Create(), Password, Salt).Decrypt(EncryptedInput, Encoding.Unicode);//5
When decrypting, the Password Salt and Keysize need to be the same for generating the same key.
More advanced
Encrypting with an already created key:
Encryption easyEncryption = new Encryption(Aes.Create(), Key);
Encryption easyEncryption = new Encryption(Aes.Create(), Encryption.CreateKey(Keysize, Password, Salt));
Encryption easyEncryption = new Encryption(Aes.Create(), Encryption.CreateKey(Algorithm, Password, Salt));
Example of encrypting/decrypting with the other algorithms:
encryptedString = new Encryption(TripleDES.Create(), Password, Salt).Encrypt(Input);
decryptedString = new Encryption(TripleDES.Create(), Password, Salt).Decrypt(EnryptedInput);
encryptedString = new Encryption(DES.Create(), Password, Salt).Encrypt(Input);
decryptedString = new Encryption(DES.Create(), Password, Salt).Decrypt(EnryptedInput);
encryptedString = new Encryption(RC2.Create(), Password, Salt).Encrypt(Input);
decryptedString = new Encryption(RC2.Create(), Password, Salt).Decrypt(EnryptedInput);
encryptedString = new Encryption(Rijndael.Create(), Password, Salt).Encrypt(Input);
decryptedString = new Encryption(Rijndael.Create(), Password, Salt).Decrypt(EnryptedInput);
Encrypting with an already configured algorithm:
SymmetricAlgorithm algorithm = Aes.Create();
algorithm.Key = Encryption.CreateKey(algorithm,Password,Salt);
Encryption easyEncryption = new Encryption(algorithm);
encryptedString = easyEncryption.Encrypt(Input);
decryptedString = easyEncryption.Decrypt(EncryptedInput);
File encryption.
The fileEncryption class constructors are the same as the constructors for the Encryption class.
Example of encrypting and decrypting a file:
FileEncryption easyEncryption = new FileEncryption(Aes.Create(),PASSWORD,SALT);
easyEncryption.Encrypt(InputFile1,OutputFile1);
easyEncryption.Decrypt(InputFile2, OutputFile2);
InputFile1 is the location of the file to encrypt. OutputFile1 is the location where to save the encrypted file.
InputFile2 is the location of the encrypted file. OutputFile2 is the location where to save the decrypted file.
Overloads of all functions
Overloads of the constructor:
Encryption(SymmetricAlgorithm algorithm)
Encryption(SymmetricAlgorithm algorithm, byte[] key)
Encryption(SymmetricAlgorithm algorithm, string password, string salt, int iterations = 10000)
Encryption(SymmetricAlgorithm algorithm, int keySize, string password, string salt, int iterations = 10000)
Overloads of the CreateKey method(NOTE, THIS METHOD IS STATIC):
static byte[] CreateKey(int keySize, string password, string salt, int iterations = 10000)
static byte[] CreateKey(SymmetricAlgorithm algorithm, string password, string salt, int iterations = 10000)
Overloads of the Encryption functions:
string Encrypt(string text)
string Encrypt(string text, Encoding encoder)
byte[] Encrypt(byte[] data)
string Decrypt(string text)
string Decrypt(string text, Encoding encoder)
byte[] Decrypt(byte[] data)
byte[] GetKey()
Overloads of the FileEncryption functions:
Encrypt(string inputFile, string outputFile, int bufferSize = 1048576)
Decrypt(string inputFile, string outputFile, int bufferSize = 1048576)
byte[] GetKey()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|