On Jul 27, 2:18 pm, Michael Glaesemann <g... / seespotcode.net> wrote:
> On Jul 27, 2007, at 14:15 , tim.j.stew... / gmail.com wrote:
>
> > Here is a session I had with irb:
>
> > [200]~% irb
> > irb(main):001:0> require 'digest/sha1'
> > => true
> > irb(main):002:0> Digest::Sha1.new.hexdigest('fdjslk')
>
> Spelling (capitalization) and calling error? I don't think you [need|
> should use] new.
>
> $ ruby --version
> ruby 1.8.6 (2007-03-13 patchlevel 0) [powerpc-darwin8.9.0]
> $ irb
> irb(main):001:0> require 'digest/sha1'
> => true
> irb(main):002:0> Digest::SHA1.hexdigest('fdjslk')
> => "df3d3f2922e369f348a90a5f65aef87f80e03fa7"

Yep, it's caused by this misguided piece of code from digest.rb:

def self.const_missing(name)
    case name
    when :SHA256, :SHA384, :SHA512
      lib = 'digest/sha2.so'
    else
      lib = File.join('digest', name.to_s.downcase)
    end

    begin
      require lib
    rescue LoadError => e
      raise LoadError, "library not found for class Digest::#{name} --
#{lib}"
    end

    Digest.const_get(name)
end

I'd call this a bug, personally.

Regards,

Dan