Hello..!!
i write code given below to encrypt text but i get error
string Does not contain definition for left.
the name Encoding is does not exist in current context.
actually this code is converted from VB.net to C#.net
anybody help me what can i do
private static string Encrypt(string strText, string strEncrKey)
{
byte[] byKey = { };
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(string.Left(strEncrKey.ToString(), 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception ex)
{
return ex.Message;
}
}
Thanks in advance.