|
-
December 17th, 2003, 03:14 PM
#1
MD5 checksum help!
I'm trying to use MD5 to calculate a checksum of a file an object was created from, and then store the file's checksum in the object for comparison later... and I'm having a problem that may be the way I'm storing it. I'm storing the checksum like this: unsigned char CheckSum[16] but I'm wondering id it's better to store it as 4 Ints? Anyone have any idea using MD5?
Last edited by Thresher; December 17th, 2003 at 03:36 PM.
-
December 18th, 2003, 01:54 AM
#2
I think using "unsigned char*" as pointer to buffer of 128 bit it's ok. But what is your problem?
-
December 18th, 2003, 10:52 PM
#3
Well.... I was storing the checksum as an unsigned char checksum[16] and had a few problems... like I tried to copy it using strcpy (w/o casting it.. &#$%#) and I was wondering if I should just store is as int1, int2 int3 int4 and not as a char[16]. Anyway I got the unsigned char[16] to work ... it just took this noob forever! When you say just have a "pointer to a 128 bit buffer"... are you suggusting a whole different checksum object? I thought of this but I didn't have alot of time left to get this done.
-
December 19th, 2003, 06:50 AM
#4
You can not use strcpy to copy the hash (checksum).
Always use memcpy, because strcpy copies the characters until it finds some \0 character and your checksum may contain such characters before strcpy reaches the end of your checksum.
So for copying the check sum use following scenario:
unsigned char CheckSum[16];
//Retreiving CheckSum
...
memcpy(lpBuffer, CheckSum, 16);
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
|