Class: SimpleSigner
- Inherits:
-
Object
- Object
- SimpleSigner
- Defined in:
- lib/simple_signer/signer.rb
Class Method Summary collapse
Class Method Details
.escape(token) ⇒ Object
32 33 34 |
# File 'lib/simple_signer/signer.rb', line 32 def self.escape token token.empty? ? token : CGI.escape(token) end |
.sign(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/simple_signer/signer.rb', line 23 def self.sign = {} raise 'secret_key is required!' unless .include?(:secret_key) and [:secret_key] raise 'string is required!' unless .include?(:string) and [:string] signed = OpenSSL::HMAC.digest('sha1', [:secret_key], [:string].encode('utf-8')) Base64.encode64(signed).strip end |
.unescape(token) ⇒ Object
36 37 38 |
# File 'lib/simple_signer/signer.rb', line 36 def self.unescape token (token.empty? or not token.include?('%')) ? token : CGI.unescape(token) end |