Invalid signature with Bittrex API calls in C# -


i trying access wallet balances in bittrex via bittrex's api calls, reason i'm getting response message saying invalid_signature.

i use these functions create signature:

getnonce

private string getnonce() {     long ms = (long)((datetime.utcnow - new datetime(1970, 1, 1)).totalseconds);      return ms.tostring(); } 

getapisignature

private string getapisignature(string key, string message) {     using (var hmacsha512 = new hmacsha512(encoding.utf8.getbytes(key)))     {         hmacsha512.computehash(encoding.utf8.getbytes(message));         return string.concat(hmacsha512.hash.select(b => b.tostring("x2")).toarray());     }        } 

here's how "compile" calls:

public string apiquery(string requesturl) {      url = new uri(requesturl);     webreq = webrequest.create(url);      signature = getapisignature(apisecret, requesturl);     webreq.headers.add("apisign", signature );      webresp = webreq.getresponse();     stream = webresp.getresponsestream();     strread = new streamreader(stream);      string rtn = strread.readtoend();      return rtn; } 

i getting same signature python api wrapper same url , nonce etc., cannot access balances. when call doesn't require signatures, works fine... not sure @ i'm doing wrong this.

got answer elsewhere. looks encoding wrong, , didn't work because of (though thought tried other encoders...).

the correct encoding ascii, whereas used utf-8.

here's function got:

private string genhmac(string secret, string url) {     var hmac = new hmacsha512(encoding.ascii.getbytes(secret));     var messagebyte = encoding.ascii.getbytes(url);     var hashmessage = hmac.computehash(messagebyte);     var sign = bitconverter.tostring(hashmessage).replace("-", "");      return sign; } 

the problem solved , works should. :-)


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -