PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → How to handle  multi-line string in HashString ?
How to handle multi-line string in HashString ?
Iniciado por Mick, 26,ene. 2021 06:03 - 1 respuesta
Publicado el 26,enero 2021 - 06:03
hi, i am mick. i have a rough problem in using HashString.

when the string is multi-line, the hash result is wrong.

i use code:
strHttpString is string = [
i am

]
strResult is string = Lower(BufferToHexa(HashString(HA_SHA_160,StringToUTF8(strHttpString)),NoGrouping,NoLine))
Trace(strResult)


or

strHttpString is string ="i am" + CR
strResult is string = Lower(BufferToHexa(HashString(HA_SHA_160,StringToUTF8(strHttpString)),NoGrouping,NoLine))
Trace(strResult)


the windev result is "19af6844c098b8b31aed426ab72901cf034276d2"

But the right result should be "b4b1f1eda0ed819f19aee3b5f296887ee17019aa"

How to use newline characters in HashString?

Thanks
Publicado el 26,enero 2021 - 12:43
I think your problem is to say that the RIGHT result is this or that... Instead, tell us WHERE you are getting this DIFFERENT result...

In windows, the next line is defined by CR+LF, so the CR constant in wlanguage adds in fact TWO characters... If your RIGHT result is coming from a LINUX source (or equivalent), then it's probably using ONLY LF, and that would account for your DIFFERENCE.

The hashstring function is working fine ... it is just working with what YOU are giving it