Signature generation error with HMAC SHA256
powerpamm opened this issue · comments
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???
Is your timestamp the same? Are your parameters in the same order? maybe post your code.
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);`