public void GetProvider() { SymmetricStorageEncryptionProvider provider = new SymmetricStorageEncryptionProvider(new DpapiSymmetricCryptoProvider(DataProtectionScope.CurrentUser, (byte[])null)); byte[] plainText = new byte[] { 0, 1, 2, 3, 4 }; byte[] encrypted = provider.Encrypt(plainText); Assert.IsFalse(CompareBytes(plainText, encrypted)); byte[] decrypted = provider.Decrypt(encrypted); Assert.IsTrue(CompareBytes(plainText, decrypted)); }
public void GetProvider() { SymmetricStorageEncryptionProviderData data = new SymmetricStorageEncryptionProviderData(); data.Name = "symm1"; data.SymmetricInstance = "dpapi1"; SymmetricStorageEncryptionProvider provider = new SymmetricStorageEncryptionProvider(); provider.ConfigurationName = "InMemoryPersistenceWithSymmetricEncryption"; provider.Initialize(new CachingConfigurationView(Context)); byte[] plainText = new byte[] {0, 1, 2, 3, 4}; byte[] encrypted = provider.Encrypt(plainText); Assert.IsFalse(CompareBytes(plainText, encrypted), "enc"); byte[] decrypted = provider.Decrypt(encrypted); Assert.IsTrue(CompareBytes(plainText, decrypted), "dec"); }
public void GetProvider() { SymmetricStorageEncryptionProviderData data = new SymmetricStorageEncryptionProviderData(); data.Name = "symm1"; data.SymmetricInstance = "dpapi1"; SymmetricStorageEncryptionProvider provider = new SymmetricStorageEncryptionProvider(); provider.ConfigurationName = "InMemoryPersistenceWithSymmetricEncryption"; provider.Initialize(new CachingConfigurationView(Context)); byte[] plainText = new byte[] { 0, 1, 2, 3, 4 }; byte[] encrypted = provider.Encrypt(plainText); Assert.IsFalse(CompareBytes(plainText, encrypted), "enc"); byte[] decrypted = provider.Decrypt(encrypted); Assert.IsTrue(CompareBytes(plainText, decrypted), "dec"); }