From: Sean Hussey Date: 2005-12-14T01:54:22+09:00 Subject: How to get an MD5 Base64 hash? 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= Base64.b64encode(np.hash.to_s) # => OTAzMjEy # From http://rubyforge.org/snippet/detail.php?type=snippet&id=33 h1=[].clear 16.times{ h1.push(np.hexdigest.to_s.slice!(0,2).hex) } [h1.pack("C*")].pack("m") # => XV1dXV1dXV1dXV1dXV1dXQ== None of the resulting strings works. What am I missing? Thank you! Sean