Professional Web Applications Themes

md5 - Ruby

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, Gergely<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 --+...

  1. #1

    Default 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, Gergely<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 --+

    KONTRA Guest

  2. #2

    Default Re: md5

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

    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"

     


    messju Guest

  3. #3

    Default Re: md5

    On 1223, messju mohr wrote: 
    >
    > require 'md5'[/ref]
    [...]

    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

    --
    +-[ Kontra, Gergely<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 --+


    KONTRA Guest

  4. #4

    Default Re: md5

    Speaking of which, where can I find doentation 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: 
    >
    >
    > 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"
    >
    >

    >
    >
    >[/ref]

    Carl Guest

  5. #5

    Default Re: md5

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

    The two are closely related :)

    Gavin


    Gavin Guest

  6. #6

    Default Re: md5

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

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


    messju Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139