本文介绍了主人MediaFire REST API会话签名SHA1?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图连接到使用他们的API主人MediaFire 的。

据该documen的 get_session_token 请求所需的参数之一就是:

According to the documen the get_session_token request one of the required parameters is:

签名:电子邮件+密码+ APPLICATION_ID + API密钥:包含此顺序以下4个元素的SHA1散列字符串。例如,电子邮件:[email protected],密码:111111,APPLICATION_ID:9999和API密钥:ABCDEFGHIJKLMNOPQRST,那么签名的计算方法如下:SHA1('[email protected]')

我遇到的问题是与SHA1,我不知道如何散列字符串到所需的SHA1。我使用.NET(我试过多种方法),但我甚至尝试与Python( hashlib.sha1('令牌')。hexdigest()),它没科技工作(试图通过互联网浏览器访问)。

The problem I'm having is with the SHA1, I don't know how to hash the string to the desired SHA1.I'm using .NET (and I tried several ways) but I even tried with python (hashlib.sha1('token').hexdigest()) and it didn't work (tried accessing via Internet browser).

有没有人经历过这个问题?

Has anyone experienced this issue before?

推荐答案

这是模式生成的字符串再一些散列数据presentations当我按照排序:

This is the sort of pattern I follow when creating string representations of some hashed data:

string data = "[email protected]";
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();

这篇关于主人MediaFire REST API会话签名SHA1?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 12:35