md5 object problem
Bobb Fwed
Posts: 1,119
I can't get the MD5 object to work, there are no samples or notes on how to use it, so this is what I am trying (looks correct anyway):
and what I get in nstr is: one line down, and 11 or so in: 8vA_ Ұ
not, the 16 byte string I was expecting.
I've gotten other weird results with other input strings. What am I doing wrong?
CON MAX_STR_LEN = 25 OBJ MD5 : "MD5" VAR byte nd[noparse][[/noparse]MAX_STR_LEN] byte nstr[noparse][[/noparse]MAX_STR_LEN] PUB do_hash bytemove(@nd, string("abcdefghijklmn 1234567890"), MAX_STR_LEN) MD5.hash(@nd, MAX_STR_LEN, @nstr)
and what I get in nstr is: one line down, and 11 or so in: 8vA_ Ұ
not, the 16 byte string I was expecting.
I've gotten other weird results with other input strings. What am I doing wrong?
Comments
The do_hash call will create a 16 byte hash in nstr. Note that this hash is not in displayable form.
It consists of 16 bytes with values from 0 to 255. You have to display the bytes in hexadecimal or
decimal form to make any sense of them. There are hexadecimal display routines in most of the
display objects (serial.hex(<value>,<#digits>) for example).
It seems to return something legit, but it doesn't match the MD5 I know works (on PSPad and PHP).
Prop MD5: B1963AC8BCB9905FE513D45A98633210
PSPad MD5: 63d7f5da7e0c01fec14ca1cf9016541f
any ideas?
Post Edited (Bobb Fwed) : 10/6/2008 5:49:46 PM GMT
Something doesn't seem right.
Post Edited (Bobb Fwed) : 10/6/2008 5:51:26 PM GMT
I've done it both ways, and see the bytemove is required to get the correct hash, just don't understand why.
Can anyone elaborte?
Thanks,
Scott
But this is probably what should be used.
Both output the correct value: "63D7F5DA7E0C01FEC14CA1CF9016541F"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
April, 2008: when I discovered the answers to all my micro-computational-botherations!