Easy License 非常容易使用,為了驗證一個軟件,你需要下面3個步驟。
1: Create a public/private Key.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (File.Exists("privateKey.xml") || File.Exists("publicKey.xml")) { var result = MessageBox.Show("The key is existed, override it?", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.No) { return; } } var privateKey = ""; var publicKey = ""; LicenseGenerator.GenerateLicenseKey(out privateKey, out publicKey); File.WriteAllText("privateKey.xml", privateKey); File.WriteAllText("publicKey.xml", publicKey); MessageBox.Show("The Key is created, please backup it."); |
2: Use private key to create a license
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (!File.Exists("privateKey.xml")) { MessageBox.Show("Please create a license key first"); return; } var privateKey = File.ReadAllText(@"privateKey.xml"); var generator = new LicenseGenerator(privateKey); var dictionary = new Dictionary<string, string>(); // generate the license var license = generator.Generate("EasyLicense", Guid.NewGuid(), DateTime.UtcNow.AddYears(1), dictionary, LicenseType.Standard); txtLicense.Text = license; File.WriteAllText("license.lic", license); |
3: Use public key to validate the license
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | private static void ValidateLicense() { if (!File.Exists("publicKey.xml")) { MessageBox.Show("Please create a license key first"); return; } var publicKey = File.ReadAllText(@"publicKey.xml"); var validator = new LicenseValidator(publicKey, @"license.lic"); try { validator.AssertValidLicense(); } catch (Exception ex) { Console.WriteLine(ex.Message); } |
EasyLicense 內部有一個叫 LicenseTool 的工具,你可以下載源代碼,運行,來看看它是怎樣的創建Key,創建Licens 和驗證License 的。

并且系統還有一個Demo 的項目,可以幫助你。

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。