I have a DB with SSN. I would like to encrypt using HashBytes with salt.
I ran
UPDATE tablex
SET essn=HashBytes('SHA1',ssn+salt)
it runs correctly but when I query for WHERE
essn=HashBytes('SHA1','111-11-2222salt') it does not find the record
ssn is a nvchar column salt is also nvchar column
Please help. Thx
Dan Guzman - 08 Oct 2005 02:10 GMT
> ssn is a nvchar column salt is also nvchar column
In that case, specify a Unicode string:
WHERE ssn=HashBytes('SHA1', N'111-11-2222salt')

Signature
Hope this helps.
Dan Guzman
SQL Server MVP
>I have a DB with SSN. I would like to encrypt using HashBytes with salt.
>
[quoted text clipped - 7 lines]
> ssn is a nvchar column salt is also nvchar column
> Please help. Thx