F. Senault
2/23/2009 10:02:00 AM
Le 23 février 2009 à 10:44, Paul Golea a écrit :
> Thank you very much to the person who will have the solution of my
> problem.
If you are under Windows, you need to open the file in binary mode.
(Well, arguably, you always need to open binary files in binary mode).
For instance :
Z:\>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
Z:\>irb
>> require "zlib"
=> true
>> f = File.read('bibi.jpg') ; nil
=> nil
>> Zlib.crc32(f,0).to_s(16)
=> "332c7941"
>> f = nil
=> nil
>> File.open('bibi.jpg', 'rb') { |h| f = h.read } ; nil
=> nil
>> Zlib.crc32(f,0).to_s(16)
=> "5ba68c3c"
And the second CRC corresponds to what other tools give me.
Fred
--
You ask me if I've known love
And what it's like to sing songs in the rain Well, I've seen love come
And I've seen it shot down I've seen it die in vain
Shot down in a blaze of glory (Bon Jovi, Blaze of Glory)