Skip to content

Instantly share code, notes, and snippets.

@bmarini
Created May 26, 2010 21:59
Show Gist options
  • Save bmarini/415134 to your computer and use it in GitHub Desktop.
Save bmarini/415134 to your computer and use it in GitHub Desktop.
# Goal:
# Authenticate a params hash with an authenticity_token
require 'openssl'
secret = "9d0d287c71f2e2629ca34bdbc03772509b815a4d2ad6392c7a436249698a29f34d2883d3cb640d9fbdd0a7fc45b42c6fa293d6119d97aeb324c0b1eeafb51e19"
params = {:a => 'a', :b => 'b', :c => 'b'}
params[:_authenticity_token] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('SHA1'), secret, params.values.join)
p params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment