Inicio → WINDEV 24 → SHA256 of Windev is different to MySQL's
SHA256 of Windev is different to MySQL's
Iniciado por Juan, 09,ene. 2019 16:52 - 3 respuestas
Publicado el 09,enero 2019 - 16:52

I am trying to hash the passwords using:
sPassword is string = "MiContraseña"
sClave is string = HashString(HA_SHA_256, sPassword)
tmp is string

FOR i=1 _TO_ Length(sClave)
tmp += Right(NumToString(Asc(sClave[[i]]),"08x"), 2)
ToClipboard(tmp) // b536931076054627e24dcebf50140c8374bf80b079fa017e91c72f48e8109eff

If I try
SELECT SHA2('MiContraseña', 256)

it will return '1ef1870f76d31f4b5e877996faf904fd5214135c9967100ff3eda9f568b4d751', which is obviously different from the output made by Windev 22.

Am I missing something, doing something wrong...?

Thank you.
Miembro registrado
33 mensajes
Publicado el 11,enero 2019 - 11:03

I'm not sure, but could it be that windev uses SHA1 vs SHA2?
Publicado el 11,enero 2019 - 12:52

I tried making everything an ANSI String, and it worked.

Apparently the problem here is when you set the strings to UNICODE...

I have still that problem, some passwords will for sure contain special characters, and for some reason, when hashing the same ANSI string in UNICODE it will give a different output... I need to find a fix / workaround for that.
Miembro registrado
213 mensajes
Publicado el 11,enero 2019 - 18:21
Hi. Well, knowing that, you can convert unicode text into ANSI and vice versa. On the other hand HashString returns a buffer and not a string, since the result can contain non-printable characters.