MediaFire Rest API session signature SHA1?
Asked Answered
M

1

2

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: [email protected], password: 111111, application_id: 9999, and API key: abcdefghijklmnopqrst, then signature should be calculated as follows: SHA1('[email protected]')

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?

Mosira answered 10/3, 2013 at 23:39 Comment(0)
H
3

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();
Haiphong answered 11/3, 2013 at 0:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.