Skip to content

Instantly share code, notes, and snippets.

@peterwillcn
Forked from bentonporter/gist:2891463
Created March 22, 2016 15:12
Show Gist options
  • Select an option

  • Save peterwillcn/6e1c375ff93ca3f77619 to your computer and use it in GitHub Desktop.

Select an option

Save peterwillcn/6e1c375ff93ca3f77619 to your computer and use it in GitHub Desktop.
Ruby - HMAC-SHA256 example
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment