checksum calculation for file offsets

I

Ironhide

Hi,

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
both.

Any idea how to go about dealing with the offsets?
 
J

Jürgen Exner

Ironhide said:
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
both.

Any idea how to go about dealing with the offsets?

All the MD5 modules I have seen accept text as input. So just read those
parts from both files and then run the MD5 algorithm on the extracted
text.

jue
 
S

Steve C

Ironhide said:
Hi,

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
both.

Any idea how to go about dealing with the 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top