I have an application where I need to encrypt part of the URL so the user cannot see the parameter that is being passed. I am doing so using the method...
private const string rgbIVChars = "randomkeyhere";
private const string keyChars = "randomkeyhere";
public static string EncryptString(string ClearText)
{
byte[] clearTextBytes = Encoding.UTF8.GetBytes(ClearText);
System.Security.Cryptography.SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
MemoryStream ms = new MemoryStream();
byte[] rgbIV = Encoding.ASCII.GetBytes(rgbIVChars);
byte[] key = Encoding.ASCII.GetBytes(keyChars);
CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write);
cs.Write(clearTextBytes, 0, clearTextBytes.Length);
cs.Close();
return Convert.ToBase64String(ms.ToArray());
}
It works out great for most cases but while testing, I noticed that sometimes I will get a backslash cha ...
Go to the complete details ...