小编mis*_*ema的帖子

C#中使用Bittrex API调用的签名无效

我试图通过Bittrex的API调用在Bittrex中访问我的钱包余额,但由于某种原因,我收到回复消息说INVALID_SIGNATURE.

我使用这些函数来创建签名:

GetNonce

private String GetNonce()
{
    long ms = (long)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);

    return ms.ToString();
}
Run Code Online (Sandbox Code Playgroud)

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());
    }       
}
Run Code Online (Sandbox Code Playgroud)

这是我如何"编译"我的电话:

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;
} …
Run Code Online (Sandbox Code Playgroud)

c# api signature hmac

5
推荐指数
1
解决办法
3555
查看次数

标签 统计

api ×1

c# ×1

hmac ×1

signature ×1