Skip to content

Instantly share code, notes, and snippets.

@nolim1t
Created August 6, 2015 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolim1t/c568641b2048a9922741 to your computer and use it in GitHub Desktop.
Save nolim1t/c568641b2048a9922741 to your computer and use it in GitHub Desktop.
Signing a string with crypto in ruby
require "openssl"
require "base64"
def sign(key, str)
ssl_sign = OpenSSL::HMAC.digest("sha512", key, str)
return Base64.encode64(ssl_sign).to_s.gsub("\n","")
end
@nolim1t
Copy link
Author

nolim1t commented Aug 6, 2015

Example Code

puts sign("test", "hello world")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment