R
Robert Lynch
How do you compute the md5sum of a cdrom you have burned? Googling
seems to reveal this to be a "difficult" problem. The complaint is
something like: "I burned the CD, but now the md5sum is different than
the one posted on the download site!"
It appears to me that the problem is related to file block size,
padding, etc.
One can find the size of a cd-rom in linux using the command "isosize"
(from util-linux package). Then you can (hack, hack, chop, mangle...)
compute it as follows:
===
# $Id: md5.pl,v 1.2 2003/07/17 17:15:11 user Exp user $
# reads md5sum from unmounted CD-ROM in drive
# run as perl -w md5.pl
use Digest::MD5;
# CD-ROM device file on my system.
$file = "/dev/scd0";
# Install/adjust path to isosize depending on distro
my $size = `/usr/bin/isosize $file`;
#print "Size of $file: $size\n";
# Read $size bytes into a variable
# Perl Cookbook, p. 276
# TODO - read chunks, compute md5sum
# so as not to bog down system.
open FH, $file or die "Couldn't open $file: $!\n";
my $read = sysread(FH, $data, $size, 0);
close FH;
# Lifted from Digest::MD5 man page
my $md5 = Digest::MD5->new;
$md5->add($data);
$digest = $md5->hexdigest;
print "$digest - $file\n";
===
I'm sure you whizzes will take one whiff of this (while holding your
noses) and then immediately come up with something neater and perlish.
But in the meantime: "There's More Than One Way To Do It."
Bob L.
seems to reveal this to be a "difficult" problem. The complaint is
something like: "I burned the CD, but now the md5sum is different than
the one posted on the download site!"
It appears to me that the problem is related to file block size,
padding, etc.
One can find the size of a cd-rom in linux using the command "isosize"
(from util-linux package). Then you can (hack, hack, chop, mangle...)
compute it as follows:
===
# $Id: md5.pl,v 1.2 2003/07/17 17:15:11 user Exp user $
# reads md5sum from unmounted CD-ROM in drive
# run as perl -w md5.pl
use Digest::MD5;
# CD-ROM device file on my system.
$file = "/dev/scd0";
# Install/adjust path to isosize depending on distro
my $size = `/usr/bin/isosize $file`;
#print "Size of $file: $size\n";
# Read $size bytes into a variable
# Perl Cookbook, p. 276
# TODO - read chunks, compute md5sum
# so as not to bog down system.
open FH, $file or die "Couldn't open $file: $!\n";
my $read = sysread(FH, $data, $size, 0);
close FH;
# Lifted from Digest::MD5 man page
my $md5 = Digest::MD5->new;
$md5->add($data);
$digest = $md5->hexdigest;
print "$digest - $file\n";
===
I'm sure you whizzes will take one whiff of this (while holding your
noses) and then immediately come up with something neater and perlish.
But in the meantime: "There's More Than One Way To Do It."
Bob L.