Questions about compress(1) and shar(1)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions about compress(1) and shar(1)

Thorsten Glaser
Hello people,

I've got some questions:

* For a given set of files, does shar(1) always produce the
  same output (if given these files sorted), respectively,
  if the (e.g.) RIPEMD-160 checksum of all input files stays
  the same (I don't care about mtime, etc.), the resulting
  file's RIPEMD-160 should be constant?
* Is shar(1) binary-safe?
* For a given input file, does compress(1) always produce
  the same output (i.e. if the RIPEMD-160 of the input is
  the same, the output's RIPEMD-160 will always be the same
  as well)?

Thanks a lot in advance!

bye,
//mirabile
--
> emacs als auch vi zum Kotzen finde (joe rules) und pine f|r den einzig
> bedienbaren textmode-mailclient halte (und ich hab sie alle ausprobiert). ;)
Hallooooo, ich bin der Holger ("Hallo Holger!"), und ich bin ebenfalls
... pine-User, und das auch noch gewohnheitsmd_ig ("Oooooooohhh").  [aus dasr]

Reply | Threaded
Open this post in threaded view
|

Re: Questions about compress(1) and shar(1)

Otto Moerbeek
On Fri, 11 Nov 2005, Thorsten Glaser wrote:

> Hello people,
>
> I've got some questions:
>
> * For a given set of files, does shar(1) always produce the
>   same output (if given these files sorted), respectively,
>   if the (e.g.) RIPEMD-160 checksum of all input files stays
>   the same (I don't care about mtime, etc.), the resulting
>   file's RIPEMD-160 should be constant?

yes.

> * Is shar(1) binary-safe?

no. If you would have tried you would have known.

> * For a given input file, does compress(1) always produce
>   the same output (i.e. if the RIPEMD-160 of the input is
>   the same, the output's RIPEMD-160 will always be the same
>   as well)?

AFAIK compress is a function in the mathematical sense. Same input
will produce same output.

Depending on how it's uses gzip it's the same with gzip (by default
gzip stores a filename and a timestamp, but you can avoid that by
making it read from a pipe, for example).

But what you are asking is not true. There are infinite files with the
same hash. They won't compress to the same file or a file that has the
same hash.

        -Otto

Reply | Threaded
Open this post in threaded view
|

Re: Questions about compress(1) and shar(1)

Thorsten Glaser
Otto Moerbeek dixit:

>> * Is shar(1) binary-safe?
>
>no. If you would have tried you would have known.

If I try, I get only probes for specific sets of input data.
I thought it would be better to ask someone who "knows".

>AFAIK compress is a function in the mathematical sense. Same input
>will produce same output.

Thanks a lot. (And a bit further searching, the file format doesn't
seem to add stuff like original filename, time stamps etc.)

>But what you are asking is not true. There are infinite files with the
>same hash. They won't compress to the same file or a file that has the
>same hash.

Ow. Error in thinking while trying to phrase it.
But thanks, you've helped me a lot.

bye,
//mirabile
--
<ciruZ> Vutral: ohne [...] kram sinds 46 Zeilen. Wozu also ein Tutorial?
<benz> ciruz: weil die zeilen alle ausssehen wie m/@!,.*[0-9]*$/; $_=$`
<benz> executable line noise -- Benny zu Perl im MirOS IRC Channel
<benz> shell+awk > perl -- Die Antwort, ein paar Tage spdter.

Reply | Threaded
Open this post in threaded view
|

Re: Questions about compress(1) and shar(1)

Miod Vallat
> >> * Is shar(1) binary-safe?
> >
> >no. If you would have tried you would have known.
>
> If I try, I get only probes for specific sets of input data.
> I thought it would be better to ask someone who "knows".

Such as its manpage in the BUGS section?