Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- checksum calculation for file offsets
April 26, 2010, 3:28 pm
rate this thread
This is what I am trying to achieve.
Create a copy of a file.
User inputs starting offset and end offset for the file.
For this range the perl program should calculate the md5sum
for both the original file and the copied file and compare them
Any idea how to go about dealing with the offsets?
Re: checksum calculation for file offsets
Digest::Perl::MD5 is a pure perl implementation. You could hack
the addfile method to add optional start and end offset arguments.
It would just add a seek to start, and only read end-start bytes
instead of to end of file. (Off-by-one error left to the astute).
If you need better performance use the addfile method for
Digest::MD5. Rather than hack C source and rebuild, it might be
easier to read from STDIN. In bash this would be:
dd if=myfile ibs=1 skip=$START count=$(( $END - $START )) | mymd5sum.pl
- » FAQ 7.10 How do I adopt or take over a module already on CPAN?
- — Next thread in » PERL Discussions
- » FAQ 4.27 How can I access or change N characters of a string?
- — Previous thread in » PERL Discussions