Created
September 26, 2009 05:13
-
-
Save dominiek/194033 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
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")) | |
key = EzCrypto::Key.with_password(USERVOICE_ACCOUNT_KEY, USERVOICE_API_KEY) | |
encrypted = key.encrypt(options.to_json) | |
@data = CGI.escape(Base64.encode64(encrypted).gsub(/\n/, '')) # Remove line returns where are annoyingly placed every 60 characters | |
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