Skip to content

Instantly share code, notes, and snippets.

@pingzh
Last active May 22, 2016 05:33
Show Gist options
  • Save pingzh/dc1f7e1ebe33aef3add1 to your computer and use it in GitHub Desktop.
Save pingzh/dc1f7e1ebe33aef3add1 to your computer and use it in GitHub Desktop.
## hexdiget to digest
hexdigest = Digest::MD5.hexdigest("ping")
digest = hexdigest.scan(/../).map(&:hex).pack("C*")
## digest to hexdigest
digest = Digest::MD5.digest('http://www.example.com')
hexdigest = digest.unpack('H*').first
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment