我们有一个C#应用程序,需要保护它不被非法复制。因此我们决定使用Portable.Licensing库来保护我们的系统。
我如何在Portable.Licensing中将许可证绑定到硬件id,以便只有特定的PC才能使用许可证?
发布于 2015-06-08 10:08:52
您可以在PC的名称、硬件信息等上生成唯一的哈希,并在许可证创建期间将此哈希作为Additional Attribute添加。
许可证创建示例:
var license = License.New()
.WithUniqueIdentifier(Guid.NewGuid())
.As(LicenseType.Standard)
.WithMaximumUtilization(1)
.WithAdditionalAttributes(new Dictionary<string, string>
{
{"HardwareId", "........"}
})
.LicensedTo("John Doe", "john.doe@yourmail.here")
.CreateAndSignWithPrivateKey(privateKey, passPhrase);要验证属性,可以实现自己的验证扩展方法,或者只使用现有的AssertThat()。例:1
唯一硬件id的生成超出了便携式许可的范围。
发布于 2016-08-22 12:13:39
您可以调用AsserThat方法:
license.Validate()
.AssertThat(lic => lic.ProductFeatures.Get("HardwareId") == "133456", new GeneralValidationFailure() { Message="Invalid Hardware.", HowToResolve="Contact administrator"});发布于 2018-06-19 01:54:56
使用ProtectedData.Protect和DataProtectionScope.LocalMachine加密许可文件中的一些密钥值对。只有当该值可以在同一台机器上成功解密时,许可证才有效。
ProtectedData.UnProtect只会在加密的同一台机器上解密。不过,这需要在注册过程中进行桌面/客户端服务器交互。
https://stackoverflow.com/questions/30587116
复制相似问题