Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void getBalanceV2()
- {
- RestRequest req = signRequestV2(new RestRequest("money/info", Method.POST));
- var resp = rc2.Execute<dynamic>(req);
- }
- public RestRequest signRequestV2(RestRequest req)
- {
- String apiKey = ConfigurationManager.AppSettings["MtGoxAPIKey"];
- String apiSecret = ConfigurationManager.AppSettings["MtGoxApiSecret"];
- TimeSpan span = DateTime.Now - UnixEpoch;
- double seconds = span.TotalSeconds * 10000;
- Int64 nonce = (Int64)seconds;
- string endpoint = req.Resource.ToString();
- string post = "nonce=" + nonce;
- string prefix = endpoint;
- string sign = getHash(Convert.FromBase64String(apiSecret), prefix + Convert.ToChar(0) + post);
- req.AddHeader("Rest-Key", apiKey);
- req.AddHeader("Rest-Sign", sign);
- req.AddParameter("nonce", nonce);
- return req;
- }
- public string getHash(byte[] keyByte, String message)
- {
- var hmacsha512 = new HMACSHA512(keyByte);
- var messageBytes = encoding.GetBytes(message);
- return Convert.ToBase64String(hmacsha512.ComputeHash(messageBytes));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement