public void GenerationTest() { var hash = RawInput.ComputeHash(); var dateString = DateNow.ToString("ddMMyyyy"); var hashAndProductAndDate = InsertProductAndDate(NUnit3Product + dateString, Nunit3PosArray, hash); var guidSalt = FileHelper.GetGuid(); var elb = ReversibleEncryption.Encrypt(PublicKey, hashAndProductAndDate + guidSalt); var writableLicence = elb.AsHex(); //Start undoing what we did var elbAfterAsHexAsBytes = writableLicence.AsBytes(); Assert.That(StructuralComparisons.StructuralEqualityComparer.Equals(elb, elbAfterAsHexAsBytes)); var decryptedLicenceBytes = ReversibleEncryption.Decrypt(PublicKey, elbAfterAsHexAsBytes); Assert.That(decryptedLicenceBytes.Equals(hashAndProductAndDate + guidSalt)); var restoredHashAndProductAndDate = decryptedLicenceBytes.Remove(decryptedLicenceBytes.Length - 36); Assert.That(restoredHashAndProductAndDate.Equals(hashAndProductAndDate)); var restoredHash = ExtractProductAndDate(Nunit3PosArray, restoredHashAndProductAndDate); Assert.That(restoredHash[1].Equals(hash)); Assert.That(restoredHash[0].Equals(NUnit3Product + dateString)); }
public void LicenceStringIsValidContent() { const string licence = "0C01614ADE00BC13BEFF530C5D93E1B10CD917B35FE98A94BA7738159BEC679ACF0C5C68D5C7F1AB91AA85D5E8CA37345B291547E76A5147D615EF23C25422D269F8A202F7EBE394D83292F764CFA83C7D994D02DA6A278BE7F2A7A869947D99F2B32A6E4FC3A8713E755339E8DE357FB86E6883645BA37DB8E16170B4B24308"; var writtenActivationKeyGS = ReversibleEncryption.Decrypt(PublicKey, licence.AsSauceryBytes()); var writtenGS = writtenActivationKeyGS.ExtractGuidSalt(); const string expectedGuidSalt = "d010fe00-bd6a-4c94-85ff-da9ba45b769d"; var sauceryActivationKey = writtenActivationKeyGS.Remove(writtenActivationKeyGS.Length - 36); Assert.That(Hasher.ProductAndDateIsValid(sauceryActivationKey) && StringComparer.OrdinalIgnoreCase.Compare(expectedGuidSalt, writtenGS) == 0); }