Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using RestSharp;
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace Hitbtc.Api.Demo
class Program
static void Main(string[] args)
const string apiKey = "xxx";
const string secretKey = "yyy";
var client = new RestClient("");
var request = new RestRequest("/api/1/trading/balance", Method.GET);
request.AddParameter("nonce", GetNonce());
request.AddParameter("apikey", apiKey);
string sign = CalculateSignature(client.BuildUri(request).PathAndQuery, secretKey);
request.AddHeader("X-Signature", sign);
var response = client.Execute(request);
private static long GetNonce()
return DateTime.Now.Ticks * 10 / TimeSpan.TicksPerMillisecond; // use millisecond timestamp or whatever you want
public static string CalculateSignature(string text, string secretKey)
using (var hmacsha512 = new HMACSHA512(Encoding.UTF8.GetBytes(secretKey)))
return string.Concat(hmacsha512.Hash.Select(b => b.ToString("x2")).ToArray()); // minimalistic hex-encoding and lower case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.