Created
September 25, 2009 07:26
-
-
Save dominiek/193380 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'rubygems' | |
require 'ezcrypto' | |
require 'json' | |
require 'cgi' | |
require 'base64' | |
module Uservoice | |
class Token | |
attr_accessor :data | |
def initialize(options = {}) | |
options.merge!(:expires => (Time.now.utc + (5 * 60)).strftime("%Y/%m/%d %H:%M:%S +0000")) | |
puts options.to_json | |
key = EzCrypto::Key.with_password(USERVOICE_ACCOUNT_KEY, USERVOICE_API_KEY) | |
encrypted = key.encrypt(options.to_json) | |
puts key.decrypt(encrypted) | |
@data = Base64.encode64(encrypted).gsub(/\n/, '') # Remove line returns where are annoyingly placed every 60 characters | |
#puts @data | |
puts @data | |
puts key.decrypt(Base64.decode64(@data)) | |
end | |
def to_s | |
@data | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment