|
-
Apr 11th, 2007, 07:18 AM
#1
Thread Starter
Addicted Member
UDT to MD5?
Has anyone tried to get the MD5 hash of an UDT? I'm getting and sending a type through sockets and need to check/send the hash of the message body, but right now I have no way of checking if the values I'm getting are right or are completely wrong since I've never used MD5.
I have the clsMD5 class found on freeVBCode, but actually I'm not fully sure of how to proceed...
Any help?
-
Apr 11th, 2007, 07:25 AM
#2
Re: UDT to MD5?
How does the UDT look like ?
can you post the code for the UDT ?
-
Apr 11th, 2007, 07:34 AM
#3
Thread Starter
Addicted Member
Re: UDT to MD5?
I must use different types of UDTs, but all of them look more of less the same way, for example:
vb Code:
Public Type tBody
msgTop As msgHeader
msgSpecificZoneA1 As Long
msgSpecificZoneA2 As Long
End Type
And the header type is something like:
vb Code:
Public Type msgHeader
msgType As Long
msgDate As Long
msgLength As Long
End Type
-
Apr 11th, 2007, 08:16 AM
#4
Frenzied Member
Re: UDT to MD5?
How does the clsMD5 want to receive the data?
If these UDTs only contain longs then you could put them into an array of longs.
For UDTs that are built differently you could use the copymemory api to put the contents of the udt into an array
-
Apr 11th, 2007, 09:35 AM
#5
Thread Starter
Addicted Member
Re: UDT to MD5?
 Originally Posted by jeroen79
How does the clsMD5 want to receive the data?
If these UDTs only contain longs then you could put them into an array of longs.
For UDTs that are built differently you could use the copymemory api to put the contents of the udt into an array
I already use copymemory for the socket protocol, so that's not problem. Looking a bit more at the class it seems it's just enough with making:
vb Code:
Dim md5Converter As New MD5
md5Converter.MD5Init
md5Converter.MD5Update UBound(btBuff), btBuff
md5Converter.MD5Final
md5Sum = md5Converter.getValues()
But again, I have no way of checking this against some real values... so I don't know if I'm making this in the right way heh.
-
Apr 11th, 2007, 10:00 AM
#6
Re: UDT to MD5?
It is the right way...
To double check, save the UDT in a file, then MD5 the file, and check if you get the same result.
-
Apr 11th, 2007, 12:25 PM
#7
Frenzied Member
-
Apr 11th, 2007, 01:54 PM
#8
Re: UDT to MD5?
 Originally Posted by jeroen79
What is btbuff?
He used CopyMemory API to copy the UDT data into a byte array, and btbuff is that array...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|