Module: Dingtalk::Signature
Instance Method Summary collapse
Instance Method Details
#signature(secret, timestamp = (Time.current.to_f * 1000).round) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/apis/dingtalk/signature.rb', line 5 def signature(secret, = (Time.current.to_f * 1000).round) raise ArgumentError, 'timestamp must in millis' if Math.log10().ceil < 13 origin_str = [, secret].join("\n") signature_str = OpenSSL::HMAC.digest('SHA256', secret, origin_str) signature_str_base64 = Base64.strict_encode64(signature_str) URI.encode_www_form_component(signature_str_base64) end |