Thoughts on secure hashing and the "mds" algorithm Almost a decade ago Raymond Chen blogged [1] about the "hash reset
attack" cautioning developers to record the content length in addition
to the message digest.

Recently I came up with a variation on the MD5 hashing algorithm that
incorporates the file size. I've called this algorithm 'MDS' for
'Message Digest + Size' but hilariously "MDS" is a "cancer"... :P

You can see the javascript or PHP implementation of MDS [2].

So, is this a good idea? Do you think it would raise the bar for
collision generation? I'm way out of my depth... sort of seems like a
good idea, but I'm not armed with facts.

Perhaps, as I have been cautioned, I shouldn't be using MD5 at all..?

[1] http://blogs.msdn.com/b/oldnewthing/archive/2004/05/19/134937.aspx
[2] https://svn.jj5.net/jjrepo/mds/trunk/src/
That is an absolutely terrible idea, here is why.
His algorithm works as follows:

Hash the input data
Take the length of data (presumably in bytes)
TRUNCATE the hash so that the length value in bytes plus the truncated hash is the output length of a standard MD5 hash (128 bits)

Here is an example of a 1MB data file being hashed
MD5(data) = e319709e00ec584c412603b83f661b2b
len(data) = 40000000
MDS(data) = e319709e00ec584c412603b840000000

Most MD5 collision attacks are on signatures with a fixed length, this will only make it easier to create a collision, since you do not have to worry about the truncated bits at the end as part of your collision calculation.
The length of the input data for some applications is also a secret or can expose information about the data, so it is part of the input padding to the hash and not the output.