using System.Security.Cryptography;
private const string requestLine = "POST https://api.notserv.com/updates HTTP/1.1\n";
private const string host = "api.notserv.com";
private const string date = "Fri, 18 Sep 2020 08:57:24 GMT";
private const string contentLength = "593";
private const string body =
- id: 8fb16f51-4955-4fa7-a926-e36ab9ecddf8
self: /datapoints/8fb16f51-4955-4fa7-a926-e36ab9ecddf8
timestamp: 2021-02-17T17:17:17Z
- id: 8fb16f51-4955-4fa7-a926-e36ab9ecddf9
self: /datapoints/8fb16f51-4955-4fa7-a926-e36ab9ecddf9
timestamp: 2021-02-17T17:17:17Z";
private const string secret = "TheBestPasswordEver";
private const string concatString = requestLine + host + date + contentLength + body;
public static void Main()
Console.WriteLine("Hash: " + hash);
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.Unicode.GetBytes(secret)))
var bytes = Encoding.Unicode.GetBytes(stringToSign);
var hashedBytes = hmacsha256.ComputeHash(bytes);
return Convert.ToBase64String(hashedBytes);