tags:

views:

93

answers:

2

i'm using mssql 2000. i have 3 problem.

  1. My web site save some data to html formatted text into ntext field. how to search from this field?
  2. Before i ask question named by how to search from all field in sql. But i need to get which field found search result?
  3. I save some field using .NET encryption. How to search from this field. It is possible?

Help me please

Thanks

A: 

You can use LIKE or PATINDEX() to search for a wildcard expression within a ntext (or nvarchar(max)) column.

Mitch Wheat
A: 

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, "&%#@?,:*");
ebattulga
What were you expecting anyone would do with this?
Mitch Wheat
When i insert data to sql, i'm using this encryption. For example, i have table named tUser, tUser has 2 field named username and password. When i add new user, encrypt password field(for example before passoword='aaa', after encrypt password='FDSw>gF'). I need to select from this field in mssql
ebattulga
is it possible? Do you understand my problem? My english is bit of poor, sorry :(
ebattulga