Skip to content

Instantly share code, notes, and snippets.

@dominiek
Created September 25, 2009 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominiek/193380 to your computer and use it in GitHub Desktop.
Save dominiek/193380 to your computer and use it in GitHub Desktop.
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