コード例 #1
0
        public void TestStringDecryption()
        {
            _encryption = new StringEncryption(new AesCryptoServiceProvider());
            byte[] encrypted = _encryption.EncryptStringToBytes(_password, _key);

            string unencrypted = _encryption.DecryptStringFromBytes(encrypted, _key);
            Assert.AreEqual(unencrypted, _password);
        }
コード例 #2
0
        public void TestStringDecryptionDoesNotDecryptForInvalidPassword()
        {
            _encryption = new StringEncryption(new AesCryptoServiceProvider());
            var decryption = new StringEncryption(new AesCryptoServiceProvider());
            byte[] encrypted = _encryption.EncryptStringToBytes(_password, _key);
            Encoding enc = new UnicodeEncoding();
            byte[] badPassBytes = enc.GetBytes("2dor39tp");

            decryption.DecryptStringFromBytes(encrypted, badPassBytes);
        }
コード例 #3
0
 public void TestStringEncryption()
 {
     _encryption = new StringEncryption(new AesCryptoServiceProvider());
     byte[] encrypted = _encryption.EncryptStringToBytes(_password, _key);
     Assert.NotNull(encrypted);
 }