Different HashBytes Value

  • Hi,

    Currently, i am working on 2005 Encryption on our history data, which has many millions of rows with sensitive data. I am fine with Encryption. But, having problem with searches using FrontEnd application. I have decided to go with HashBytes for giving search on the sensitive data. When i test hash, it's generating different values. Which is correct or which method is better to choose ?

    DECLARE @CRD CHAR(19)

    SET @CRD = '1234567890123456'

    SELECT CONVERT(BINARY(20), HashBytes('SHA1', @CRD))

    SELECT CONVERT(BINARY(20), HashBytes('SHA1', '1234567890123456'))

    Thanks,

    Moorthy

  • Try the same code with VARCHAR datatype. It should work.

    DECLARE @CRD VARCHAR(19) -- Replaced CHAR(19) with VARCHAR(19)

    SET @CRD = '1234567890123456'

    SELECT CONVERT(BINARY(20), HashBytes('SHA1', @CRD))

    SELECT CONVERT(BINARY(20), HashBytes('SHA1', '1234567890123456'))

  • Thanks Dev. I didn't think about it.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply