LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2012, 02:22 AM   #1
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Wheezy, Webmin + Virtualmin (remote dedi)
Posts: 214

Rep: Reputation: 30
[Solved] Is it possible to alter the hash value of an archive ?


Hello,

I'm wondering something, is there a way, please, to change/alter/modify the hash value of an archive, of Zip format ?

Technically, I know it would only require to add or remove a file to this archive, but my idea is to achieve that result
. on a distant Debian server only accessible through shell (honestly : this makes commodities like the right-click impossible, and it's a pity )
. without adding or removing files to the archive

I thought of extracting the contents of the archive, and recompressing them with another compression ratio (from deflate to store, or a different speed of compression - source : Zip's man page), maybe...
However, it would quickly turn into a real mess : extract the archive, recompress it, delete the folder to which the extraction has been done...

Besides, I'm also considering doing that for a group of zip archives, not just one, so that would be done as a suffix to a "find ... - exec" command. That's another reason to avoid doing too much of a complicated mess

So, maybe, who knows, might there be a faster solution ?

Thank you very much if you can help

Good day everyone,
Sabinou

Last edited by Sabinou; 03-10-2012 at 06:02 AM.
 
Old 02-24-2012, 02:55 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 343Reputation: 343Reputation: 343Reputation: 343
Hi there,

Quote:
Originally Posted by Sabinou View Post
I'm wondering something, is there a way, please, to change/alter/modify the hash value of an archive, of Zip format ?
yes, there is: By altering its contents.

Quote:
Originally Posted by Sabinou View Post
I thought of extracting the contents of the archive, and recompressing them with another compression ratio (from deflate to store, or a different speed of compression - source : Zip's man page), maybe...
Technically, that would do the job. Or just change one single character in the archive description. But what for?

Quote:
Originally Posted by Sabinou View Post
However, it would quickly turn into a real mess : extract the archive, recompress it, delete the folder to which the extraction has been done...
Not really; once you figured out the parameters for recompression, you'd make a script (batch file) that does it all by itself, including removal of the temporary directory.

I still wonder what purpose this is supposed to serve, though.

[X] Doc CPU
 
1 members found this post helpful.
Old 02-24-2012, 05:01 AM   #3
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Wheezy, Webmin + Virtualmin (remote dedi)
Posts: 214

Original Poster
Rep: Reputation: 30
Thanks for the reply, DocCPU !

Various replies :

- "why ?" : It's complicated. But, basically, I have a script that "remembers" which archives he processed based on their hash he has memorized, and who refuses to process again files he already processed for complicated reasons, and I want this program to still process these archives again.

- "Or just change one single character in the archive description" : errrr, what is that "archive description", is it the --entry-comments ?
 
Old 02-24-2012, 05:22 AM   #4
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 343Reputation: 343Reputation: 343Reputation: 343
Hi there,

Quote:
Originally Posted by Sabinou View Post
- "why ?" : It's complicated. But, basically, I have a script that "remembers" which archives he processed based on their hash he has memorized, and who refuses to process again files he already processed for complicated reasons, and I want this program to still process these archives again.
okay, I see. But I think that's a bad approach. Changing the contents of a file to force re-processing ... hmm, I'd rather use something different, like maintaining a list which files have been processed. Then you can easily delete an item from the list and your script will see that file as "new", when it runs next time.

Off topic: I know that English and French are quite different (I speak some French, too, though not very good), and that French grammar has no neutrum. But if you're talking about things like a script, a program, a computer, it's always "it" in English, not "he". Only use "he" or "she" in connection with persons (there are very few exceptions, though, like pets, or ships).

Quote:
Originally Posted by Sabinou View Post
- "Or just change one single character in the archive description" : errrr, what is that "archive description", is it the --entry-comments ?
Erm, probably. I'm not sure about the details, but I know that many popular archive formats (zip, rar, 7z) allow to put a comment into the archive. Well, I spontaneously called it "description", but probably we mean the same.

[X] Doc CPU

Last edited by Doc CPU; 02-24-2012 at 05:24 AM.
 
Old 02-25-2012, 03:20 PM   #5
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Wheezy, Webmin + Virtualmin (remote dedi)
Posts: 214

Original Poster
Rep: Reputation: 30
I didn't have time since the last time, but I am back, at last

I tried a bit my hand, and if only, o wishful imagination, all my archives had contained one common same file, it would have been as simple as a "zip -f" with another version of that file.

However, the contents of the archives vary, grr

So, now, I'm back to try to add comments to the archive, with the zip -c or --entry-comments command. The problem is that this is going to ask me to add comments to EACH AND EVERY FILE of the archive. And then press enter. Manually.
Ew.

And yet :
- I know, that on Windows systems, the program winrar allows to add a comment to an archive without selecting a file in particular
- I know, without knowing how it can be done, that it's possible to tell a command "always do that in a situation", which would solve the matter of the manual comments submission. Just in case, I tried "zip -fvc archive.zip | test", but, as I suspected, it wasn't the proper way to act, for an archive with seven files, 5 MB large, nothing happened anymore inside my shell during 3 whole minutes, as if the program was stuck doing something :lol:

Does someone have a lead ? Many thanks, once again
 
Old 02-26-2012, 04:42 AM   #6
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 841

Rep: Reputation: 201Reputation: 201Reputation: 201
Quote:
- "why ?" : It's complicated. But, basically, I have a script that "remembers" which archives he processed based on their hash he has memorized, and who refuses to process again files he already processed for complicated reasons, and I want this proging ram to still process these archives again.
The remembering portion must be based on stored data (of already procesed hashes). So try to purge this remembered data by some other program/script before running your script.

OK
 
Old 02-26-2012, 05:16 AM   #7
haveanother
LQ Newbie
 
Registered: Jan 2011
Posts: 13

Rep: Reputation: 0
To change the HASH value of a zip archive without changing its contents, you can try this command:

Code:
export FILENAME=hello.zip ; export FILESIZE=`wc -c $FILENAME | sed -e 's/^\([0-9]*\).*$/\1/'` ; dd if=/dev/zero of=$FILENAME skip=$FILESIZE oflag=append conv=notrunc bs=1 count=1
This appends a zero byte to the end of the file. This makes the zip file HASH different, but the contents of the zip archive will be the same when extracted.

Make a backup copy of your files before you try this.

EDIT: of course you need to change the hello.zip to the name of your zip file (maybe with full path, if you are in a different directory)

Last edited by haveanother; 02-26-2012 at 05:19 AM.
 
Old 03-10-2012, 06:02 AM   #8
Sabinou
Member
 
Registered: Jan 2006
Location: France
Distribution: Debian Wheezy, Webmin + Virtualmin (remote dedi)
Posts: 214

Original Poster
Rep: Reputation: 30
The logic behind this command is beyond my understand, but it worked, so thank you very much, Haveanother
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Hash of Hash reference query kdelover Programming 1 02-19-2011 04:47 AM
[SOLVED] How do I change ca.archive.ubuntu.com to ca2.archive.ubuntu.com at the command line kennymw Linux - Newbie 3 09-01-2009 02:52 AM
need help unpacking hmac-md5 hash into md5 hash lynx5 Programming 3 02-02-2008 04:06 PM
Using hash value as key for other hash in Perl scuzzman Programming 6 02-14-2006 05:08 PM
importing an MS Outlook archive archive.pst alloydog Linux - Software 2 08-29-2003 03:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration