رمزگشایی(Decrypt )یک رشته (String)
private Byte[] KEY = { 0x54, 0x54, 0x98, 079, 0x35, 0x48, 0x97, 0x12 };
private Byte[] IV = { 0x08, 0x19, 0x24, 0x87, 0x39, 0x43, 0x16, 0x71, 0x38, 0x62, 0x93, 0x55, 0x29, 0x32, 0x95, 0x97 };
public String Decrypt(String Text)
{
if (Text != "")
{
try
{
Byte[] TextBytes = Convert.FromBase64String(Text);
RijndaelManaged rijKey = new RijndaelManaged();
rijKey.Mode = CipherMode.CBC;
ICryptoTransform decryptor = rijKey.CreateDecryptor(KEY, IV);
MemoryStream memoryStream = new MemoryStream(TextBytes);
CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read);
Byte[] pTextBytes = new byte[TextBytes.Length];
Int32 decryptedByteCount = cryptoStream.Read(pTextBytes, 0, pTextBytes.Length);
memoryStream.Close();
cryptoStream.Close();
String plainText = Encoding.UTF8.GetString(pTextBytes, 0, decryptedByteCount);
Text = "";
rijKey.Clear();
decryptor.Dispose();
memoryStream.Dispose();
cryptoStream.Dispose();
return plainText;
}
catch
{
String t = "";
return t;
}
}
else
{
return Text;
}
}