Skip to content

Instantly share code, notes, and snippets.

@sonkm3
Created July 29, 2013 09:43
Show Gist options
  • Save sonkm3/6103270 to your computer and use it in GitHub Desktop.
Save sonkm3/6103270 to your computer and use it in GitHub Desktop.
ruby: get base64 encoded sha1 hash. (for OAuth signature)
require "openssl"
key = "123"
base_string = "abc"
hash = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA1.new, key, base_string)
p [hash].pack('m').gsub(/\n/, '')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment