public void EncryptThenDecryptProducesPlainText() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var keyId = keyRing.CurrentKeyId; var personalDataProtector = new AspNetCoreIdentityEncryption.PersonalDataProtector(keyRing); var cipherText = personalDataProtector.Protect(input); var plainText = personalDataProtector.Unprotect(cipherText); Assert.Equal(input, plainText); }
public void RoatingTheKeyRingDoesNotBreakDecryption() { const string input = "*****@*****.**"; var keyRing = new KeyRing(); var keyId = keyRing.CurrentKeyId; var personalDataProtector = new AspNetCoreIdentityEncryption.PersonalDataProtector(keyRing); var cipherText = personalDataProtector.Protect(input); keyRing.CreateAndActivateNewKey(); var plainText = personalDataProtector.Unprotect(cipherText); Assert.Equal(input, plainText); }