Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have a rar file, and I want to change the file hash (MD5) of it, what's the fastest way of doing this?

I'm thinking I could add a byte to the end of it, which should change the hash... But I'm not sure how to do this. I need to be able to extract the files inside without a problem as well.

Would appreciate any help!

NB: I've already done it with archive comments, but that takes a while, so I'm looking for something faster & less CPU intensive.

share|improve this question
You should provide an answer to the question "what are you really trying to do?", since I suspect there are better ways to accomplish the end goal. – Daniel Andersson Mar 14 '12 at 10:48
You change the checksum of a file by modifying its contents. The minimum modification is to flip a single bit. That or adding/removing a byte would be the easiest way to alter a file's chucksum. How to do this without corrupting the file depends entirely on the filetype. – Lèse majesté Mar 14 '12 at 12:04
@Daniel: I'm uploading a file to a filehost, and I want the hash to be unique. Anyway, figured it out, can't believe how simple it was lol – lelouch Mar 14 '12 at 18:10
"I want the hash to be unique" - still, I'm wondering what you are really trying to do. Why must the hash be unique? – Daniel Andersson Mar 14 '12 at 20:19

You can open the file with vim, cat or any hexeditor.

BUT: You will damage the file header and footer and the archive will not be recognized as a archive anymore. Yes, there are fields inside the data structure where you can write arbitrary data (cf. steganography), but it is very probable that you will damage the file.

So, just try it with one of the editors mentioned above.

share|improve this answer

Ok i figured it out! For my purposes it's as simple as echoing a 0 onto a file.


echo 0 >> test.rar

This changes the MD5 of my rar file, while leaving the contents inside unchanged.

share|improve this answer
Please note that this, most likely, only works because the un-rar process ignores the trailing 0. I think it would be a lot safer to extract and re-package the file (and possibly add a comment into the archive). – Oliver Salzburg Mar 14 '12 at 18:14
as Oliver said, this is luck that your package still works. There are many files where adding random bytes would destroy the file. Most archives have checksums and would fail any random byte adding. – Rich Homolka Mar 14 '12 at 19:01
Ah k, thanks for the clarification :) – lelouch Mar 14 '12 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .