protected virtual EncryptedKeyCipher GetCipher(bool base64 = false) { using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName)) { cipher.Base64Encoded = base64; return(cipher.CloneLightCipher() as EncryptedKeyCipher); } }
public void GetDuplicateWithShouldEncryptIVTest() { var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName) { ShouldEncryptIV = true, }; cipher.CloneLightCipher(); }
protected override EncryptedKeyCipher GetCipher(bool base64 = false) { var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName) { Base64Encoded = base64, }; cipher.ReleaseCertificate(); return(cipher); }
public static void ClassCleanup() { const string expected = "The quick fox jumps over the lazy dog."; var keyManagement = new EncryptedKeyCipher(CertificateFactory.GetEncryptingCertificate(), null, expected) as IKeyManagement; if (keyManagement.KeyLocation.EndsWith(expected, StringComparison.InvariantCultureIgnoreCase) && File.Exists(keyManagement.KeyLocation)) { File.Delete(keyManagement.KeyLocation); } }
public virtual void OriginalCanDecryptFromDuplicate() { const string expected = "The quick fox jumps over the lazy dog."; using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), expected)) { cipher.ExportSymmetricKey(); using (var dupe = cipher.CloneLightCipher()) { var encrypted = dupe.Encrypt(expected); var decrypted = cipher.Decrypt <string>(encrypted); Assert.AreEqual(expected, decrypted); } } }
public override void DuplicateCanDecryptFromOriginal() { const string expected = "The quick fox jumps over the lazy dog."; using (var cipher = new EncryptedKeyCipher(CertificateFactory.GetDecryptingCertificate(), _keyFileName)) { cipher.ExportSymmetricKey(); var encrypted = cipher.Encrypt(expected); cipher.ReleaseCertificate(); var decrypted = cipher.Decrypt <string>(encrypted); Assert.AreEqual(expected, decrypted); } }