Code/SboxSuperuser/Core/Commands/RequestFingerprint.cs

Utility that computes a deterministic fingerprint for a command and its arguments. It JSON-serializes an anonymous object with fields command and arguments, hashes the UTF-8 bytes with SHA-256, and returns the hex string of the digest.

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 ) ) );
	}
}