Standalone .NET 4.7.2 console tool for NcProgramManager offline licensing. - keygen: RSA 2048-bit key pair generation - fingerprint: WMI machine fingerprint (Windows only) - sign: RSA-SHA256 sign fingerprint, write .lic file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace LicenseGenerator.Commands
|
|
{
|
|
internal static class SignCommand
|
|
{
|
|
internal static void Execute(InputArgs args)
|
|
{
|
|
if (string.IsNullOrEmpty(args.KeyPath))
|
|
{
|
|
Console.Error.WriteLine("Missing: -key=<path-to-private.key.xml>");
|
|
Environment.Exit(1);
|
|
}
|
|
if (string.IsNullOrEmpty(args.Fingerprint))
|
|
{
|
|
Console.Error.WriteLine("Missing: -fingerprint=<machine-fingerprint>");
|
|
Environment.Exit(1);
|
|
}
|
|
|
|
string privateXml = File.ReadAllText(args.KeyPath);
|
|
byte[] data = Encoding.UTF8.GetBytes(args.Fingerprint);
|
|
|
|
using (var rsa = new RSACryptoServiceProvider())
|
|
{
|
|
rsa.FromXmlString(privateXml);
|
|
byte[] signature = rsa.SignData(data, new SHA256CryptoServiceProvider());
|
|
string base64 = Convert.ToBase64String(signature);
|
|
File.WriteAllText(args.OutPath, base64);
|
|
Console.WriteLine("License written: " + args.OutPath);
|
|
}
|
|
}
|
|
}
|
|
}
|