Results 1 to 8 of 8

Thread: UDT to MD5?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    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?

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: UDT to MD5?

    How does the UDT look like ?
    can you post the code for the UDT ?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    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:
    1. Public Type tBody
    2.     msgTop As msgHeader
    3.     msgSpecificZoneA1 As Long
    4.     msgSpecificZoneA2 As Long
    5. End Type

    And the header type is something like:

    vb Code:
    1. Public Type msgHeader
    2.     msgType As Long
    3.     msgDate As Long
    4.     msgLength As Long
    5. End Type

  4. #4
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    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

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2006
    Posts
    160

    Re: UDT to MD5?

    Quote 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:
    1. Dim md5Converter As New MD5
    2.    
    3.     md5Converter.MD5Init
    4.     md5Converter.MD5Update UBound(btBuff), btBuff
    5.     md5Converter.MD5Final
    6.  
    7.    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.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    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.

  7. #7
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: UDT to MD5?

    What is btbuff?

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803

    Re: UDT to MD5?

    Quote 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
  •  



Click Here to Expand Forum to Full Width