Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > checksum calculation for file offsets

Reply
Thread Tools

checksum calculation for file offsets

 
 
Ironhide
Guest
Posts: n/a
 
      04-26-2010
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?
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      04-26-2010
Ironhide <(E-Mail Removed)> wrote:
>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
 
Reply With Quote
 
 
 
 
Steve C
Guest
Posts: n/a
 
      04-27-2010
Ironhide wrote:
> 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:erl::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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing to different offsets of a file in parallel Ironhide Perl Misc 5 03-26-2011 12:11 AM
Need help to find byte offsets for regexps in a file Robert Dodier Perl Misc 2 07-09-2006 12:39 AM
How to determine checksum calculation method Andrus C Programming 3 10-13-2005 12:11 PM
Looking for a more elegant way to do memory offsets mikegw C Programming 5 05-24-2004 11:39 AM
OpenSP API, Unicode character byte offsets Phillip Farber XML 0 08-20-2003 09:13 PM



Advertisments