X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_bin%2Fbincompare.pl;fp=usr_bin%2Fbincompare.pl;h=0000000000000000000000000000000000000000;hb=c08b156abb0b2b1b1335cb1ada0c08758553238b;hp=767b8a397e31233ffce9c093e7c44695617b0e6f;hpb=b0c3e5ff760f99d6ff7721852bc1a0d73c5ea201;p=grml-scripts.git diff --git a/usr_bin/bincompare.pl b/usr_bin/bincompare.pl deleted file mode 100755 index 767b8a3..0000000 --- a/usr_bin/bincompare.pl +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/perl -# Filename: bincompare.pl -# Purpose: Binary File Similarity Checking -# Authors: (C) Copyright 2004 Diomidis Spinellis -# Bug-Reports: see http://grml.org/bugs/ -# License: See notes by author (Diomidis Spinellis). -################################################################################ -# See http://www.dmst.aueb.gr/dds/blog/20040319/index.html -# -# Original notes: -# -# (C) Copyright 2004 Diomidis Spinellis -# -# Permission to use, copy, and distribute this software and its -# documentation for any purpose and without fee is hereby granted, -# provided that the above copyright notice appear in all copies and that -# both that copyright notice and this permission notice appear in -# supporting documentation. -# -# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -# Return the entropy of the file passed as the argument -sub -entropy -{ - my($file) = @_; - my($i, $l); - - # File length - $l = `wc -c $file`; - # File information (approximation) - $i = `bzip2 -c $file | wc -c`; - print STDERR "$0: warning file size exceeds bzip2 block size\n" if ($l > 900 * 1024); - return ($i / $l); -} - - -# Return the entropy of the two files passed as arguments -sub -entropy2 -{ - my($file1, $file2) = @_; - my($oldrs) = ($/); - my($tmp) = ("/tmp/entropy.$$"); - - undef($/); - open(IN, $file1) || die "read from $file1: $!\n"; - binmode(IN); - open(OUT, ">$tmp") || die "write to $tmp: $!\n"; - print OUT ; - open(IN, $file2) || die "read from $file2: $!\n"; - binmode(IN); - print OUT ; - close(IN); - close(OUT); - my($e) = (entropy($tmp)); - unlink($tmp); - return ($e); -} - -$#ARGV == 1 || die "Usage $0: file1 file2\n"; - -printf("%.3g - Entropy of $ARGV[0]\n", $e0 = entropy($ARGV[0])); -printf("%.3g - Entropy of $ARGV[1]\n", $e1 = entropy($ARGV[1])); -printf("%.3g - Combined predicted entropy\n", ($e0 + $e1) / 2); -printf("%.3g - Combined actual entropy\n", entropy2($ARGV[0], $ARGV[1]));