public void TestVerifier_Full() { var expireDate = DateTime.Parse("2100-01-01", CultureInfo.InvariantCulture); var license = Lic.Builder .WithRsaPrivateKey(LicTest.PrivateKey) .WithHardwareIdentifier(HardwareIdentifier.ForCurrentComputer()) .WithSerialNumber(SerialNumber.Create("ABC")) .ExpiresOn(expireDate) .WithProperty("Prop1", "Value1") .WithProperty("Prop2", "Value2") .SignAndCreate(); var verifiedLicense = Lic.Verifier .WithRsaPublicKey(LicTest.PublicKey) .WithApplicationCode("ABC") .LoadAndVerify(license.Serialize()); Assert.AreEqual(license.Serialize(), verifiedLicense.Serialize()); verifiedLicense = Lic.Verifier .WithRsaPublicKey(LicTest.PublicKey) .WithApplicationCode("ABC") .LoadAndVerify(license.SerializeAsPlainText()); Assert.AreEqual(license.Serialize(), verifiedLicense.Serialize()); }
public void TestVerify_OneMatchingParts() { var hardwareID = HardwareIdentifier.ForCurrentComputer(); var splitted = hardwareID.Split('-'); var otherID = string.Format("1234567890-0987654321-3010203045-" + splitted[3] + "-DummycheckSum"); Assert.IsFalse(HardwareIdentifier.IsValidForCurrentComputer(otherID)); }
public void TestVerify_ThreeMatchingParts() { var hardwareID = HardwareIdentifier.ForCurrentComputer(); var splitted = hardwareID.Split('-'); var otherID = string.Format("12345678-" + splitted[1] + "-" + splitted[2] + "-" + splitted[3] + "-DummycheckSum"); Assert.IsTrue(HardwareIdentifier.IsValidForCurrentComputer(otherID)); }
public void Test_hardware_identifier_structure() { var hardwareID = HardwareIdentifier.ForCurrentComputer(); var split = hardwareID.Split('-'); Assert.AreEqual(5, split.Length); Assert.AreEqual(8, split[0].Length); Assert.AreEqual(8, split[1].Length); Assert.AreEqual(8, split[2].Length); Assert.AreEqual(8, split[3].Length); Assert.AreEqual(4, split[4].Length); }
public void Test_verify() { var hardwareID = HardwareIdentifier.ForCurrentComputer(); Assert.IsTrue(HardwareIdentifier.IsValidForCurrentComputer(hardwareID)); }