At Fri, 25 May 2001 12:11:21 +0900,
Wayne Pierce wrote:
>           case tmp[1].strip
> 
>             when md5.update(passVal).hexdigest.strip
>               print "valid account..."
>               return
> 
>             else
>               @error = "Invalid user ID or password."
>               # Print the values, if they didn't match.  Only for
> testing.
>               print md5.update(passVal).hexdigest, tmp[1]
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This should be just md5.hexdigest.  Calling update(x) twice then
hexdigest() calculates the digest value for (x + x).

>               self.loginPage(@error)
>               return
>           end

> I have a case statement in this version, I've tried if/elsif/else as
> well.  I can print out the values of tmp[1].strip and
> md5.update(passVal).hexdigest.strip; they are identical.  I've tried to
> replace either side with a string literal of the hexdigest, I've used
> .to_s to ensure they are both strings.
> 
> They match when using .type on both sides, so I know they are both
> strings.  But using .type is the only time they will match correctly.
> I've tried to use ==, =~ and eql?.

I have done it during working on the new version of the md5 module,
and it will hopefully be adopted in 1.7.

In the meantime, you can add the capability to the MD5 class as
follows:

require "md5"

class MD5
  # useful aliases
  alias << update
  alias to_s hexdigest

  # make it comparable
  include Comparable
  def <=>(other)
    hexdigest <=> other.to_s
  end
end

m = MD5.new("hi")
m == '49f68a5c8493ec2c0bf489821c21fc3b' #=> true

n = MD5.new
n << 'h'
n << 'i'

m <=> n #=> 0

-- 
                     /
                    /__  __            Akinori.org / MUSHA.org
                   / )  )  ) )  /     FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ /  ( (__(  @ iDaemons.org / and.or.jp

"Freeze this moment a little bit longer, make each impression
  a little bit stronger..  Experience slips away -- Time stand still"