Module: RongCloud::Signature
- Included in:
- Request
- Defined in:
- lib/rong_cloud/signature.rb
Overview
a seperate module to perform api signature www.rongcloud.cn/docs/server.html#通用API接口签名规则
Instance Method Summary collapse
-
#signature(nonce, timestamp) ⇒ String
generate the final signature.
-
#signed_headers ⇒ Hash
get required request headers.
Instance Method Details
#signature(nonce, timestamp) ⇒ String
generate the final signature
14 15 16 17 |
# File 'lib/rong_cloud/signature.rb', line 14 def signature(nonce, ) str = "#{RongCloud::Configuration.app_secret}#{nonce}#{}" Digest::SHA1.hexdigest(str) end |
#signed_headers ⇒ Hash
Note:
consist of the following request headers: App-Key Nonce Timestamp Signature
get required request headers
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rong_cloud/signature.rb', line 26 def signed_headers nonce = rand(10**6) = Time.now.to_i signature = signature(nonce, ) { 'App-Key' => RongCloud::Configuration.app_key, 'Nonce' => nonce, 'Timestamp' => , 'Signature' => signature } end |