AES encryption function Public static string Encrypt (string toEncrypt)
{
// 256-AES key
Byte [] keyArray = UTF8Encoding. UTF8.GetBytes ("12345678901234567890123456789012 ");
Byte [] toEncryptArray = UTF8Encoding. UTF8.GetBytes (toEncrypt );
RijndaelManaged rDel = new RijndaelManaged ();
RDel. Key = keyArray;
RDel. Mode = CipherMode. ECB;
RDel. Padding = PaddingMode. PKCS7;
ICryptoTransform cTransform = rDel. CreateEncryptor ();
Byte [] resultArray = cTransform. TransformFinalBlock (toEncryptArray, 0, toEncryptArray. Length );
Return Convert. ToBase64String (resultArray, 0, resultArray. Length );
}
AES decryption Function Public static string Decrypt (string toDecrypt)
{
// 256-AES key
Byte [] keyArray = UTF8Encoding. UTF8.GetBytes ("12345678901234567890123456789012 ");
Byte [] toEncryptArray = Convert. FromBase64String (toDecrypt );
RijndaelManaged rDel = new RijndaelManaged ();
RDel. Key = keyArray;
RDel. Mode = CipherMode. ECB;
RDel. Padding = PaddingMode. PKCS7;
ICryptoTransform cTransform = rDel. CreateDecryptor ();
Byte [] resultArray = cTransform. TransformFinalBlock (toEncryptArray, 0, toEncryptArray. Length );
Return UTF8Encoding. UTF8.GetString (resultArray );
}