Md5

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

···


±[ Kontra, Gergelykgergely@mcl.hu PhD student Room IB113 ]---------+

http://www.mcl.hu/~kgergely “Olyan langesz vagyok, hogy |
Mobil:(+36 20) 356 9656 ICQ: 175564914 poroltoval kellene jarnom” |
±- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+

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”

···

On Tue, Dec 23, 2003 at 02:21:40AM +0900, KONTRA Gergely wrote:

Gergo

[…]

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

···

On 1223, messju mohr wrote:

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’

±[ Kontra, Gergelykgergely@mcl.hu PhD student Room IB113 ]---------+
http://www.mcl.hu/~kgergely “Olyan langesz vagyok, hogy |
Mobil:(+36 20) 356 9656 ICQ: 175564914 poroltoval kellene jarnom” |
±- Magyar php mirror es magyar php dokumentacio: http://hu.php.net --+

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

messju mohr wrote:

···

On Tue, Dec 23, 2003 at 02:21:40AM +0900, KONTRA Gergely wrote:

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”

Gergo

The two are closely related :slight_smile:

Gavin

···

On Tuesday, December 23, 2003, 7:56:53 AM, Carl wrote:

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.

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.

···

On Tue, Dec 23, 2003 at 05:56:53AM +0900, Carl Youngblood wrote:

Thanks,
Carl Youngblood