MediaFire Rest API session signature SHA1?

♀尐吖头ヾ 提交于 2019-12-11 01:55:49

问题


I'm trying to connect to MediaFire using their API.

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

signature: a SHA1-hashed string that contains the following 4 elements in this sequence: email + password + application_id + API Key. For example, email: testemail@domain.com, password: 111111, application_id: 9999, and API key: abcdefghijklmnopqrst, then signature should be calculated as follows: SHA1('testemail@domain.com1111119999abcdefghijklmnopqrst')

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?


回答1:


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

string data = "testemail@domain.com1111119999abcdefghijklmnopqrst";
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();


来源:https://stackoverflow.com/questions/15329092/mediafire-rest-api-session-signature-sha1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!