Expandir la barra de logros de la comunidad.

RESUELTAS

SHA256 and SHA512 function returns wrong hash

Avatar

Level 2

Dear,

 

We would like to hash certain data in our recipients table, but do notice that the returned hash isn't the right one when we use the SHA256 or SHA512 expression. For MD5 the returned result is however the right one.

We've checked the conversion in numerous ways (cf. https://dencode.com/hash --> UTF8, UTF16, ... CRLF, LF, ...) and investigated a lot of deviations (capitals vs regular letter, spaces, ...) already.

 

Example string: 1ZZ1234

SHA256db33faa6dc66525db69058bd1b0b0a4257aa881218adc83581a2c5bc368be170
SHA256 generated by Adobe Campaign5c12c786e84b2b7f8bf4b89e5c88ded8bf6a4fd05908b63050945f9fa5b6322d
MD529e110be8987fd8403f2940a617e668d
MD5 generated by Adobe Campaign29e110be8987fd8403f2940a617e668d
SHA51238c700cd0dbcda40ba1b48605eb2485eca529bc2d2e4c04b21b15539a14098c764bc6f7693a984420dc19cfea8610c9fe485585cfc41dfcc52cc48e3eed71e19
SHA512 generated by Adobe Campaigne14c06f1c43bb65ee8487f54528a8278bbdd96582b9f23a93901fef04e3f6ed664a85308f56c5360413791bd384c14e2b0adb81b988c6c0fb05cf06530278919

 

We are using the following functions:

- Md5Digest()

- Sha256Digest()

- Sha512Digest()

 

Does anyone experienced the same or know what might be at the roots of the wrong hash generation by Adobe Campaign?

If you are a campaign user, do you get the same wrong hash?

 

Kind regards,

Wesley

Temas

Los temas ayudan a categorizar el contenido de la comunidad e incrementan la posibilidad de encontrar contenido relevante.

1 solución aceptada

Avatar

Respuesta correcta de
Level 2

Hi wodnicki,

 

Based on new offline feedback we got, we concluded that Adobe Campaign is adding "N" in front of the string value before hashing it. It does this for each unicode string. The result is a different hash than expected.

 

What Adobe Campain does:

     lower(convert(varchar(64), HashBytes('SHA2_256'), N'1ZZ1234'), 2))

 

What you would expect:

    lower(convert(varchar(64), HashBytes('SHA2_256'), '1ZZ1234'), 2))

 

This explains the difference between both hashes.

 

Wesley

Ver la solución en mensaje original publicado

3 Respuestas

Avatar

Community Advisor

Hi,

 

Hashes look fine to me. Campaign just translates those calls directly to the underlying RDBMS- For Postgres this is encode(digest('1ZZ1234', 'sha256'), 'hex').

 

Thanks,

-Jon

Avatar

Level 2

Hi wodnicki,

 

Thanks for your quick reply. I posted new insights about the problem as a separate answer.

 

Wesley

Avatar

Respuesta correcta de
Level 2

Hi wodnicki,

 

Based on new offline feedback we got, we concluded that Adobe Campaign is adding "N" in front of the string value before hashing it. It does this for each unicode string. The result is a different hash than expected.

 

What Adobe Campain does:

     lower(convert(varchar(64), HashBytes('SHA2_256'), N'1ZZ1234'), 2))

 

What you would expect:

    lower(convert(varchar(64), HashBytes('SHA2_256'), '1ZZ1234'), 2))

 

This explains the difference between both hashes.

 

Wesley