VB.NET sample code for the signature calculation
Option Explicit On
Option Strict On
Imports System
Imports System.Security.Cryptography
Imports System.Text
Namespace SignCmd
Public Module CmdSigner
Public Function SignedCommand(ByVal itemToCheck As String, ByVal keyString As String) As String
Dim encoding As ASCIIEncoding = New ASCIIEncoding()
'converting key to bytes will throw an exception, need to replace "minus" and "underscore" characters first.'
Dim privateKeyBytes As Byte() = Convert.FromBase64String(keyString.Replace("-", "+").Replace("_", "/"))
Dim encodedPathAndQueryBytes As Byte() = encoding.GetBytes(itemToCheck)
'compute the hash'
Dim algorithm As HMACSHA1 = New HMACSHA1(privateKeyBytes)
Dim hash As Byte() = algorithm.ComputeHash(encodedPathAndQueryBytes)
'convert the bytes to string and make url-safe by replacing '+' and '/' characters'
Dim signature As String = Convert.ToBase64String(hash).Replace("+", "-").Replace("/", "_")
'Return the signature.'
Return signature
End Function
End Module
Public Module Program
Sub Main()
Const keyString As String = "YOUR_PRIVATE_KEY"
Dim cmdString As String = "COMMAND_ITEM_TO_SIGN"
Console.WriteLine(CmdSigner.SignedCommand(cmdString, keyString))
End Sub
End Module
End Namespace