Guest User

Untitled

a guest
Apr 16th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. require 'rubygems'
  2. require 'ezcrypto'
  3. require 'json'
  4. require 'cgi'
  5. require 'base64'
  6.  
  7. module Uservoice
  8. class Token
  9. attr_accessor :data
  10.  
  11. def initialize(options = {})
  12. options.merge!(:expires => (Time.now.utc + (5 * 60)).strftime("%Y/%m/%d %H:%M:%S +0000"))
  13.  
  14. puts options.to_json
  15. key = EzCrypto::Key.with_password(USERVOICE_ACCOUNT_KEY, USERVOICE_API_KEY)
  16. encrypted = key.encrypt(options.to_json)
  17.  
  18.  
  19. puts key.decrypt(encrypted)
  20. @data = Base64.encode64(encrypted).gsub(/\n/, '') # Remove line returns where are annoyingly placed every 60 characters
  21. #puts @data
  22. puts @data
  23. puts key.decrypt(Base64.decode64(@data))
  24. end
  25.  
  26. def to_s
  27. @data
  28. end
  29. end
  30. end
Add Comment
Please, Sign In to add comment