md5

K

KONTRA Gergely

Hi!

Is there any efficient way to calculate the md5 hash for a file?

Reading the entire file isn't memory efficient under winxp (big file...) ;(

Gergo
 
M

messju mohr

Hi!

Is there any efficient way to calculate the md5 hash for a file?

Reading the entire file isn't memory efficient under winxp (big file...) ;(

require 'md5'

d = Digest::MD5.new
chunk = nil
md5 = nil
begin
while (chunk = STDIN.sysread(4096)) do
d.update(chunk)
end
rescue EOFError
md5 = d.to_s
end
print md5 + "\n"
 
K

KONTRA Gergely

require 'md5'
[...]

Thx.
BTW A method for calculating md5 for a file would be useful, and easy...
(I mean in the distro. I can do it for me. hope so :))

Gergo
 
C

Carl Youngblood

Speaking of which, where can I find documentation for the Digest class?
I can't find it in ruby-doc.org, and there is very little in digest.rb
class to explain how it works.

Thanks,
Carl Youngblood
 
G

Gavin Sinclair

Speaking of which, where can I find documentation for the Digest class?
I can't find it in ruby-doc.org, and there is very little in digest.rb
class to explain how it works.

The two are closely related :)

Gavin
 
M

messju mohr

Speaking of which, where can I find documentation for the Digest class?
I can't find it in ruby-doc.org, and there is very little in digest.rb
class to explain how it works.

there is a ext/digest/digest.txt in the ruby source-distribution.
 

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

Similar Threads


Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top