Reputation: 10981
I'm using Microsoft SQL Server 2000 and I have 3 problems.
ntext
field. How do I search this field?Upvotes: 0
Views: 273
Reputation: 10981
My encryption is here>>
public string Encrypt(string strText, string strEncKey)
{
Byte[] byKey;
Byte[] IV ={ 0x12, 0x34, 0x54, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byKey = Encoding.UTF8.GetBytes(strEncKey);
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());
}
public string Decrypt(string strText, string strEncKey)
{
Byte[] byKey;
Byte[] IV ={ 0x12, 0x34, 0x54, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
Byte[] inputByteArray;
byKey = Encoding.UTF8.GetBytes(strEncKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return System.Text.Encoding.UTF8.GetString(ms.ToArray());
}
Using >>
Encrypt(value, "&%#@?,:*");
Decrypt(value, "&%#@?,:*");
Upvotes: 0
Reputation: 300529
You can use LIKE or PATINDEX() to search for a wildcard expression within a ntext (or nvarchar(max)) column.
Upvotes: 1