 C# sample code for the signature calculation
C# sample code for the signature calculation
 
 
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace SignCommand {
	public struct SignedCommand {
		public static string Sign(string itemToCheck, string keyString) {
			ASCIIEncoding encoding = new ASCIIEncoding();
			// converting key to bytes will throw an exception, need to replace '-' and '_' characters first.
			string usablePrivateKey = keyString.Replace("-", "+").Replace("_", "/");
			byte[] privateKeyBytes = Convert.FromBase64String(usablePrivateKey);
			byte[] encodedCommandBytes = encoding.GetBytes(itemToCheck);
			// compute the hash
			HMACSHA1 algorithm = new HMACSHA1(privateKeyBytes);
			byte[] hash = algorithm.ComputeHash(encodedCommandBytes);
			// convert the bytes to string and make command-safe by replacing '+' and '/' characters
			string signature = Convert.ToBase64String(hash).Replace("+", "-").Replace("/", "_");
			// Return the signature.
			return signature;
		}
	}
	class Program {
		static void Main() {
			// Note: Generally, you should store your private key someplace safe
			// and read them into your code
			const string keyString = "YOUR_PRIVATE_KEY";
			const string commandString = "COMMAND_ITEM_TO_SIGN";
			Console.WriteLine(SignedCommand.Sign(commandString,keyString));
		}
	}
}