Skip to content

Instantly share code, notes, and snippets.

@tk3
Created March 12, 2015 17:38
Show Gist options
  • Save tk3/b4bb329994da0845e4ca to your computer and use it in GitHub Desktop.
Save tk3/b4bb329994da0845e4ca to your computer and use it in GitHub Desktop.
md5 hash
#require "digest"
password = 'user02'
key = '$apr1$'
salt = 'PD3O5t9N'
h1 = Digest::MD5.new
h1.update(password)
h1.update(key)
h1.update(salt)
h2 = Digest::MD5.new
h2.update(password)
h2.update(salt)
h2.update(password)
final = h2.digest
h1.update(final[0, password.length])
puts h1.hexdigest
# ruby => 32225a00ac387c93fa00296d88999851
# mruby-digest => 64ecd575be6825aea092953373318a5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment