Helper in the SboxSuperuser command package that hashes a command and its arguments. Serializes the pair to JSON and returns a SHA256 hex string, so the same request can be identified by a fingerprint.
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
namespace SboxSuperuser.Core.Commands;
internal static class RequestFingerprint
{
internal static string Compute( string command, IReadOnlyList<string> arguments )
{
var json = JsonSerializer.Serialize( new { command, arguments } );
return Convert.ToHexString( SHA256.HashData( Encoding.UTF8.GetBytes( json ) ) );
}
}