Files
ironlicensing-dotnet/MachineIdentifier.cs
David Friedel 7d453f8f63 Initial commit: IronLicensing.Client SDK
Software licensing SDK for .NET MAUI applications with:
- License validation and activation
- Feature gating
- Trial support
- Offline validation with signature verification
- In-app purchase integration
2025-12-25 09:07:58 +00:00

39 lines
1.1 KiB
C#

using System.Security.Cryptography;
using System.Text;
namespace IronLicensing.Client;
public partial class MachineIdentifier : IMachineIdentifier
{
public string GetMachineId()
{
var components = GetMachineComponents();
var combined = string.Join("|", components.Where(c => !string.IsNullOrEmpty(c)));
if (string.IsNullOrEmpty(combined))
{
// Fallback to a device-specific identifier
combined = DeviceInfo.Current.Idiom.ToString() + "|" +
DeviceInfo.Current.Manufacturer + "|" +
DeviceInfo.Current.Model;
}
using var sha256 = SHA256.Create();
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(combined));
return Convert.ToBase64String(hash)[..32];
}
public string GetMachineName()
{
return DeviceInfo.Current.Name ?? Environment.MachineName ?? "Unknown";
}
public string GetPlatform()
{
return DeviceInfo.Current.Platform.ToString();
}
// Platform-specific implementation
private partial List<string> GetMachineComponents();
}