我正在尝试连接到媒体之火 http://www.mediafire.com使用他们的 API。
根据该文件get_session_token http://developers.mediafire.com/index.php/REST_API#get_session_token请求所需参数之一是:
签名:一个 SHA1 哈希字符串,按此顺序包含以下 4 个元素:电子邮件 + 密码 + application_id + API 密钥。例如,电子邮件:[电子邮件受保护] /cdn-cgi/l/email-protection,密码:111111,application_id:9999,API密钥:abcdefghijklmnopqrst,则签名应计算如下:SHA1('[电子邮件受保护] /cdn-cgi/l/email-protection')
我遇到的问题是 SHA1,我不知道如何将字符串哈希为所需的 SHA1。
我正在使用 .NET (并且我尝试了几种方法),但我什至尝试过使用 python (hashlib.sha1('token').hexdigest()
)但它不起作用(尝试通过互联网浏览器访问)。
以前有人遇到过这个问题吗?
这是我在创建某些哈希数据的字符串表示形式时遵循的模式:
string data = "[email protected] /cdn-cgi/l/email-protection";
byte[] bytes = Encoding.UTF8.GetBytes(data);
byte[] hash;
using (SHA1 sha1 = new SHA1Managed())
hash = sha1.ComputeHash(bytes);
//You would use hashString for the signature parameter.
string hashString = BitConverter.ToString(hash).Replace("-", "").ToLower();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)