sindresorhus / gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
MIT License
1.54k stars 217 forks source link

Why not use full md5 #20

Closed milyord closed 10 years ago

milyord commented 10 years ago

Is there a particular reason why the md5 hash is sliced? Why not use the entire hash?

https://github.com/sindresorhus/gulp-rev/blob/master/index.js#L39

Thanks.

sindresorhus commented 10 years ago

Because it doesn't matter. It's unique enough for its purpose.

matsko commented 9 years ago

@sindresorhus do you have anything to back this up?

bobthecow commented 9 years ago

@matsko Maths.

8 hex characters means your rev prefix range is 0x00000000 through 0xffffffff, or in other words, enough for 4,294,967,296 unique hash prefixes. MD5 is a good (checksum) hash, meaning it's very well distributed.

So the odds of you finding two (non-equal) files that have a hash collision are approximately 5.421e-20, or 1 in 18,447,000,000,000,000,000.

… which is approximately the same as the odds of you buying two Powerball lotto tickets and winning the jackpot with both tickets.

mbrevda commented 9 years ago

Here is an argument from another angle: I like the look of a full hash. It makes things look so sophisticated! 8 characters seems so flimsy, even if the science says otherwise. Can we at least specify the cut length? (I would want at least 16 chars, if not the full hash)

sindresorhus commented 9 years ago

Feel free to modify it, but we're not going to add options just because it looks better in your opinion. The more options the more useless things the user has to consider and care about. I prefer simple interfaces.