in reply to Re^4: Digest::SHA gives different values for unix/windows
in thread Digest::SHA gives different values for unix/windows
Hi this is my first post.
Hello Monks!
Given that some OSes treat binary and text files differently (the latter messing around with line endings as you said in your first post), I think you really need a $mode argument to the Digest::SHA::addfile($filename [, $mode]) method.
Otherwise you'd have to do something like this to generate the hash of a file in binary mode:
It might cause fewer problems if Digest::SHA::addfile() defaulted to binary mode.
Hello Monks!
Given that some OSes treat binary and text files differently (the latter messing around with line endings as you said in your first post), I think you really need a $mode argument to the Digest::SHA::addfile($filename [, $mode]) method.
Otherwise you'd have to do something like this to generate the hash of a file in binary mode:
It's easier to just call Digest::SHA::addfile($filename "b")open the file set binmode while (not EOF) { read N-bytes of the file into a buffer # don't want to read the +whole file into memory if it's a big file Digest::SHA::add($buffer) } close file
It might cause fewer problems if Digest::SHA::addfile() defaulted to binary mode.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Digest::SHA gives different values for unix/windows
by Jim (Curate) on Jun 13, 2013 at 19:22 UTC | |
by zork42 (Monk) on Jun 14, 2013 at 07:07 UTC |
In Section
Seekers of Perl Wisdom