// Download OpenSSL.NET (openssl-net) library
// from https://github.com/openssl-net/openssl-net
// In your .NET project, add a reference to the ManagedOpenSsl.dll assembly.
//use headers
//using OpenSSL.Crypto;
//using System.Text;
//using System;
/// <summary>/// Method for decrypting the message
/// </summary>/// <paramname="msg">encrypted message</param>/// <returns>decrypted message</returns>public string DecryptData(string msg)
{
CipherContext AES_128_ECB = new CipherContext(Cipher.AES_128_ECB);
string encryptionKey = "d83a91f4596d7a9c199997d24f5bfb52";
var iv = Encoding.ASCII.GetBytes("12345678");
var key = Encoding.ASCII.GetBytes(encryptionKey);
using (var cc = new CipherContext(AES_128_ECB.Cipher))
{
var msgBytes = Convert.FromBase64String(msg);
var ct = cc.Decrypt(msgBytes, key, iv);
var decryptedMsg = Encoding.ASCII.GetString(ct);
Console.WriteLine("\"{0}\"", decryptedMsg);
return decryptedMsg;
}
}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.