Startbeitrag von DerekT am 14.09.2017 18:11

I have a string, 's_ToHash', populated with 3 values which when concatenated produce the string 123456789AAA3321-12BH-A2200001

I need to create an MD5 hash of that and I require the value of 507c9d79c192da6e86428919ee0382dc to be returned

WinDev returns, depending on which HashString algorithm I use either

HashString(HA_MD5_128,s_ToHash) returns 'P|yÁ’Ún†B‰î‚Ü'
HashString(HA_HMAC_MD5_128,s_ToHash) returns ')v_dÂIÊY49ñœi2éá'

The returned value is the same regardless of whether I use a Buffer or String to receive the result

I tried inputing my string into a number of online MD5 generators and all returned the ASCII result I require.

Anyone have any idea how I can convert,progamatically, the WD result into the one I need, i.e ASCII text.


It looks like you need you result in hexadecimal, if so try using BufferToHexa
or break your string byte to byte and using asc (or val i don't remember what is the right one) and numtostring you can get the hex of that byte.

von Paulo Oliveira - am 14.09.2017 18:21
Hi Derek,

you need to add a
MyResult is strin=replace(replace(BufferToHexa(MyBuffer)," ",""),CR,"")

Best regards

von Fabrice Harari - am 14.09.2017 19:06

Re: HashString SOLVED

Thanks Paulo, set me on the right course

Using BufferToHexa() returned '50 7C 9D 79 C1 92 DA 6E 86 42 89 19 EE 03 82 DC' which is actually the string I was looking for.
Just needed to reformat it.
//Create hash validation string
bufHash = HashString(HA_MD5_128,StringBuild("%1%2%3",s_AccNum,s_AccAPI,s_SubNum))

s_bufHEX = BufferToHexa(bufHash) //Convert Hash result to HEX

s_HEXTxt = s_bufHEX //Save HEX as a text string

s_MD5 = Lower(NoSpace(s_HEXTxt,sscAll)) //Format text

s_MD5 now = '507c9d79c192da6e86428919ee0382dc'

Spot on, thanks again

von DerekT - am 14.09.2017 19:07
Hi Fabrice

Much more economical withe coding - Just needed to add the Lower() command

MyResult is string=Lower(Replace(Replace(BufferToHexa(bufHash)," ",""),CR,""))

Works a treat, thanks

von DerekT - am 14.09.2017 19:14
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.