Jump to content

[SOLVED] Reducing the size of md5 checksums


PC Nerd

Recommended Posts

Hi,

 

I'm working with sending md5checksums of different strings and files to a server to validate they downloaded correctly, and I wanted to (more of an excersise than anythign else) try and reduce what I'm sending.

 

Instead of sending 10 checksums across the net, I wanted to eg. send one checksum which "represents" all the data.

 

Is:

$ck1 = md5("string");

$ck2 = ...

$ck3 = ...

$ck4 = ...

$ck5 = ...

 

md5($ck1+$ck2+$ck3+$ck4+$ck5); // Is this line a "valid" representation of the previous 5 checksums or is there a more standard method?

 

Thanks

 

 

Link to comment
Share on other sites

When you say reduce what you are sending, do you mean you want to cut down on the actual size (bytes) or the # of variables that have to be passed? If you just want to reduce the number of variables, try putting all the md5 sums in an array. Then you can reference the array and pull out any m5d sum or all of them.

 

I don't think

md5($ck1+$ck2+$ck3+$ck4+$ck5); 

is a very good idea. Manly because this will return a different md5 if the same files are sent, but in a different order. md5($ck1+$ck2+$ck3+$ck4+$ck5) != md5($ck5+$ck4+$ck3+$ck2+$ck1);

 

You could always do something like md5($ck1) + md5($ck2) and have it work for your application, but it's not truly a checksum if you do that.

Link to comment
Share on other sites

Ok - thanks all :)

 

* and to answer the first question - it was both a task of reducing the numebr of variables and the number of bytes.  ultimately - a checksum of all the data is less than individual checksums of each data entry ;)

 

Thanks - Sovled

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.