Created
April 23, 2010 17:56
-
-
Save mloughran/376898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
require 'digest/md5' | |
puts Digest::MD5.hexdigest("asdf") # => "912ec803b2ce49e4a541068d495ab570" | |
puts Digest::MD5.hexdigest("åß∂ƒ") # => "0d65ab8f1db3344230f46420e56e465f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test script to generate pusherapp auth_signature given secret and string | |
# | |
# Dependencies | |
# gem install ruby-hmac | |
# | |
require 'rubygems' | |
require 'hmac-sha2' | |
secret = '7ad3773142a6692b25b8' | |
string_to_sign = "POST\n/apps/3/channels/test_channel/events\nauth_key=278d425bdf160c739803&auth_timestamp=1272044395&auth_version=1.0&body_md5=7b3d404f5cde4a0b9b8fb4789a0098cb&name=foo" | |
hmac = HMAC::SHA256.hexdigest(secret, string_to_sign) | |
puts hmac | |
# >> 309fc4be20f04e53e011b00744642d3fe66c2c7c5686f35ed6cd2af6f202e445 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lua