Can I make 7-Zip generate identical archives when zipping the same contents twice, with encryption?

1

I'm using 7-Zip to compress/encrypt some data to store on Dropbox. I've noticed that when I use encryption, 7-Zip generates different archives from the same source files (the size is often different by a byte!).

Is there any way to make 7-Zip generate the exact same files without removing encryption?

Danny Tuppeny

Posted 2011-02-11T19:48:39.527

Reputation: 2 249

Doesn't 7zip have an option to "only update modified files"? – user1686 – 2011-02-11T19:57:05.163

Silly question, but couldn't you just copy the first one? – Jeff F. – 2011-02-11T19:58:23.310

@grawity Can't see anything like that – Danny Tuppeny – 2011-02-11T20:30:26.853

@Jeff It's my backup script. When it runs, if the resulting archive is the same as the previous one, I want to avoid Dropbox uploading it again. However, since 7zip is generating different archives for the same source files, it's always "different", and therefore Dropbox always re-uploads. – Danny Tuppeny – 2011-02-11T20:31:32.437

Try using WinMerge to figure out what the differences are. There's a 7zip plugin that will compare archives. – Chris Nava – 2011-02-11T21:07:06.367

@Chris There is no different in the archives. I ran the same command twice, outputting to two different files. 7-Zip is generating different archives for the same source files (only when encrypted). – Danny Tuppeny – 2011-02-12T12:25:44.303

Answers

4

From what I understand, 7-ZIP uses a AES256 for encryption. I am pretty sure a unique initialization vector is used each time. I don't believe there is anything you can do to change, this, and I am not sure that you would want to since it not having a unique IV each time would possibly lead to someone compromising your encryption.

If you are willing to look at alternate tools, a search for rsyncable encryption may turn up something that will help you.

Zoredache

Posted 2011-02-11T19:48:39.527

Reputation: 18 453

Looks like you're correct - I found some threads on SO saying it created a random IV. The encryption is not that important - it was just because of the way Dropbox hashes files, it's possible (but unlikely) other people will end up with the files. I'll look at an alternative way of encrypting the files. Thanks! – Danny Tuppeny – 2011-02-12T12:29:08.773

4

I found that 7zip version 4.48 stated "Now it uses random initialization vectors".

I tested an older 7zip stable version (4.42), and found that it "works" : the same file with the same password is always encrypted to the same 7zip file.

I know that this is a no good property when talking from the security point of view, but becomes quite useful when you try to store with deduplication or backup data over networks.

If you know the security implications (please read http://en.wikipedia.org/wiki/Initialization_vector), and have no problem with that, you can download and use the older 4.42 version from sourceforge https://sourceforge.net/projects/sevenzip/files/7-Zip/4.42/

FerFebles

Posted 2011-02-11T19:48:39.527

Reputation: 41

Good to know! It's a shame this isn't an option in new versions - in my case, the security wasn't critical (it's just personal files), just a small barrier in case the files are exposed. – Danny Tuppeny – 2012-07-11T09:15:41.190

You are not alone: there is a thread in the 7zip sourceforge forum https://sourceforge.net/projects/sevenzip/forums/forum/45798/topic/5339803 where you can ask for this option.

– FerFebles – 2012-07-11T11:36:07.027

@FerFebles: I just added my 2¢ to the SF thread. – martineau – 2012-08-22T18:08:33.713