[英]API sha1 hash generation not matching
我從正在運行的Slideshare API資源管理器中獲取信息:
64f43b4be73bc11a15142c1ef5dab1130c5064cb
來自以下字符串的SHA1哈希
81LqkNkvy1391428643
但是當我在Rails中使用時:
Digest::SHA1.hexdigest("81LqkNkvy1391428643")
我得到:
1ef520bb53227b9edf691d47da653f93d232e16e
我不知道為什么這不匹配。
根據Slideshare API鏈接
http://www.slideshare.net/developers/documentation
它清楚地說
hash: Set this to the SHA1 hash of the concatenation of the shared secret and the
timestamp (ts). i.e. SHA1 (sharedsecret + timestamp). The order of the terms
in the concatenation is important.
我以為我正確地遵循了指示。 我還嘗試了解密以上SHA1字符串,但到目前為止還沒有運氣。
這里可能是什么問題?
來自API資源管理器的URL參數,其共享密鑰設置為81LqkNkvy
:
...&hash=80c887e839d79dc38248ed4cda4b6ad401f57305&ts=1391434954
在Ruby中:
sharedsecret = '81LqkNkvy'
timestamp = 1391434954
require 'digest'
Digest::SHA1.hexdigest(sharedsecret + timestamp.to_s)
#=> "80c887e839d79dc38248ed4cda4b6ad401f57305"
並獲取當前時間戳:
timestamp = Time.now.to_i
#=> 1391434369
請注意,哈希值每秒更改一次。
嘗試以毫秒為單位的時間戳記?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.