Bob Showalter
12/13/2005 5:08:00 PM
Sean Hussey wrote:
> Hi everyone,
>
> I'm trying to MD5 passwords for insertion into our LDAP. I can't seem
> to get the right combination of Digest, BD5, and Base64 calls to get a
> string that works.
>
> Most passwords end up looking like this:
>
> {MD5}qLdnu5zwk43H9AYD8zmH5Q==
>
> I can manually tack on the {MD5}, of course. I've tried things along
> these lines:
>
> require 'digest/md5'
> np = Digest::MD5.new
> np << "hello"
> require 'base64'
>
> Base64.b64encode(np.to_s) # => NWQ0MTQwMmFiYzRiMmE3NmI5NzE5ZDkxMTAxN2M1OTI=
try:
Base64.b64encode(np.digest)
=> "XUFAKrxLKna5cZ2REBfFkg==\n"
to_s gives you the digest as a string of hex digits.
Documentation definitely lacking in that module ;)