From: Peter Woodsky Date: 2008-11-21T05:36:09+09:00 Subject: Re: create a md5 / md5 passwd with a salt Brian Candler wrote: > Peter Woodsky wrote: >> The forum now uses this format for storing passwords md5(md5(PASSWORD) . >> salt) where previously it was md5(PASSWORD) which was pretty easy to >> deal with. > > You should give an example of a password, a salt, and the expected > output. That's not any "standard" way of hashing an output that I've > seen. > > Is the inner md5() function producing a binary output (16 bytes) or hex > (32 characters)? Or something else, e.g. base64 (24 characters)? > > Anyway, it'll be easy enough to code if you know what you're looking > for. You can test if you're doing it right in irb. > > Example: I've arbitarily chosen inner md5 is binary, outer MD5 is hex: > > irb(main):001:0> require 'digest/md5' > => true > irb(main):002:0> Digest::MD5.digest("hello") > => "]A@*\274K*v\271q\235\221\020\027\305\222" > irb(main):003:0> Digest::MD5.digest("hello") + "mysalt" > => "]A@*\274K*v\271q\235\221\020\027\305\222mysalt" > irb(main):004:0> Digest::MD5.hexdigest(Digest::MD5.digest("hello") + > "mysalt") > => "263058590f9387d91f98266a832fabaf" From the first solution given it works as it should. All that was required was "" for the vars password and salt. md5_w_salt = Digest::MD5.hexdigest(Digest::MD5.hexdigest("#{password}") + "#{row[0]}") Thanks again! -- Posted via http://www.ruby-forum.com/.