using System.Security.Cryptography;
public static void Main()
var keyId = "8d6d26a3-2f81-459e-b668-64a922eba891";
var secret = "QDZpf2GHreX9f71ZIUEy";
const string tokenType = "AccessKey";
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
var payload = $"{tokenType} {keyId} {timestamp}";
var secretBytes = Encoding.UTF8.GetBytes(secret);
using var hmac = new HMACSHA256(secretBytes);
var hashBytes = hmac.ComputeHash(Encoding.UTF8.GetBytes(payload));
var signature = Base64Encode(ToHexString(hashBytes));
var authorizationHeader = $"{tokenType} {keyId} {timestamp} {signature}";
Console.WriteLine(authorizationHeader);
public static string ToHexString(byte[] array)
StringBuilder hex = new StringBuilder(array.Length * 2);
foreach (byte b in array)
hex.AppendFormat("{0:x2}", b);
public static string Base64Encode(string plainText)
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);