nobitavn94 Posted November 24, 2006 Share Posted November 24, 2006 Hi all ,I have a table named MasterCard with a column named Code (this column is encrypted with SHA1 algorithm and has data type is varbinary - size 100 )I want to check if a credit card exist in MasterCard table as follow :........SHA1 sha =new SHA1CryptoServiceProvider();byte[] rawBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(cardId); //cardId :credit card codebyte[] hash = sha.ComputeHash(rawBytes);//hashStringBuilder sb = new StringBuilder(hash.Length * 2 + (hash.Length / 8));int i;for (i = 0; i < hash.Length; i++){ sb.Append( BitConverter.ToString( hash, i, 1) );}string encryptedCardId = sb.ToString().TrimEnd( new char[] { ' ' } );........But I cannot use this encryptedCardId to query data even though Code column is also encrypted by SHA1 algorithm .Thanks for any response ! Link to comment Share on other sites More sharing options...
justsomeguy Posted November 27, 2006 Share Posted November 27, 2006 Why are you using varbinary? SHA-1 produces a hex string, which you can store in a 40-character varchar field, that's what I do. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now