Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Signature generation error with HMAC SHA256 #169

Open
powerpamm opened this issue Apr 21, 2020 · 2 comments
Open

Signature generation error with HMAC SHA256 #169

powerpamm opened this issue Apr 21, 2020 · 2 comments

Comments

@powerpamm
Copy link

powerpamm commented Apr 21, 2020

Issue Overview

I tried to generate signature such as in official example with the same keys but always have another result.
I tried with my own key but always gen an error 401
I use C# with Class HMACSHA256 to develop my software.

May be anybody knows how to fix it???

@raderag
Copy link

raderag commented Apr 21, 2020

Is your timestamp the same? Are your parameters in the same order? maybe post your code.

@raderag
Copy link

raderag commented Apr 21, 2020

I think this works.

` string timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
string totalParams = $"timestamp={timestamp}&recvWindow=5000";

        var messageBytes = Encoding.UTF8.GetBytes(totalParams);
        var keyBytes = Encoding.UTF8.GetBytes(secret);
        var hash = new HMACSHA256(keyBytes);
        var computedHash = hash.ComputeHash(messageBytes);
        string sig =  BitConverter.ToString(computedHash).Replace("-", "").ToLower();

        Console.WriteLine(sig);`

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants