using System.Security.Cryptography;
private const string requestLine = "POST https://api.notserv.com/updates HTTP/1.1\r\n";
private const string host = "api.notserv.com";
private const string date = "Fri, 18 Sep 2020 08:57:24 GMT";
private const string body = @"{
""id"": ""8fb16f51-4955-4fa7-a926-e36ab9ecddf8"",
""self"": ""/datapoints/8fb16f51-4955-4fa7-a926-e36ab9ecddf8""
""timestamp"": ""2021-02-17T17:17:17.000Z""
""id"": ""8fb16f51-4955-4fa7-a926-e36ab9ecddf9"",
""self"": ""/datapoints/8fb16f51-4955-4fa7-a926-e36ab9ecddf9""
""timestamp"": ""2021-02-17T17:17:17.000Z""
private static int contentLength_int = body.Length;
private static string contentLength = Convert.ToString(contentLength_int, 10);
private const string secret = "TheBestPasswordEver";
private static string concatString = requestLine + host + date + contentLength + body;
public static void Main()
Console.WriteLine("Hash: " + hash + "\n");
Console.WriteLine("Content-Length: " + contentLength + "\n");
Console.WriteLine("concatString:\n" + concatString);
private static string GetHash(string requestLine,
string host, string date, string contentLength, string body, string secret)
var stringToSign = requestLine + host + date + contentLength + body;
using (var hmacsha256 = new HMACSHA256(Encoding.UTF8.GetBytes(secret)))
var bytes = Encoding.UTF8.GetBytes(stringToSign);
var hashedBytes = hmacsha256.ComputeHash(bytes);
return Convert.ToBase64String(hashedBytes);