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 AcceptanceTest() { const string rawInput = Name + Company + Email; var dateNowString = DateTime.Now.ToString("ddMMyyyy"); var productAndDate = NUnit3Product + dateNowString; var activationKey = InsertProductAndDate(productAndDate, Nunit3PosArray, rawInput.ComputeHash()); const string myGuid = "d010fe00-bd6a-4c94-85ff-da9ba45b769d"; Assert.That(Hasher.VerifyIdentity(rawInput, activationKey)); var encryptedLicenceBytes = ReversibleEncryption.Encrypt(PublicKey, activationKey + myGuid); var writableLicence = encryptedLicenceBytes.AsHex(); Assert.That(FileHelper.LicenceStringIsValidContent(writableLicence)); }