Class: WeixinJsSDK::Signature
- Inherits:
-
Object
- Object
- WeixinJsSDK::Signature
- Defined in:
- lib/weixin_js_sdk/signature.rb
Constant Summary collapse
- TEMPLATE =
'jsapi_ticket=%{jsapi_ticket}&noncestr=%{nonce_str}×tamp=%{timestamp}&url=%{url}'.freeze
Instance Method Summary collapse
-
#initialize(ticket: '', nonce_str: '', timestamp: '', url: '') ⇒ Signature
constructor
A new instance of Signature.
- #sign ⇒ Object
Constructor Details
#initialize(ticket: '', nonce_str: '', timestamp: '', url: '') ⇒ Signature
Returns a new instance of Signature.
7 8 9 10 11 12 |
# File 'lib/weixin_js_sdk/signature.rb', line 7 def initialize(ticket: '', nonce_str: '', timestamp: '', url: '') @ticket = ticket @nonce_str = nonce_str @timestamp = @url = url end |
Instance Method Details
#sign ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/weixin_js_sdk/signature.rb', line 14 def sign str = TEMPLATE % { jsapi_ticket: @ticket, nonce_str: @nonce_str, timestamp: @timestamp, url: @url } Digest::SHA1.hexdigest(str) end |