Forum: Ruby on Rails MD5 hash from crypt and openssl different?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Eno (Guest)
on 2007-02-28 04:37
(Received via mailing list)
Im authenticating (system) users by making PAM use a MySQL database.
means Unix passwords are stored as MD5 crypted strings.

I can use "openssl passwd -1" on the command-line to generate
and set them in the database - this works just fine.

Ruby has a crypt method in the String class that does the same thing:
indeed, using str.crypt("$1$") generates a crypted string that also
when inserted into the MySQL database.

Both strings look completely different but both work just fine when
PAM authentication.

Now Im writing a web-based control panel using Rails and come up
against the problem with the MD5 crypted strings being completely
different. I can't test for equality since crypt and openssl both
different strings. I already have users using this database so
everyone's password is not an option.

So what's the best way to emulate "openssl passwd -1" for crypting
passwords in Ruby?
This topic is locked and can not be replied to.