Esempio n. 1
0
        public void Init()
        {
            _encryptionHelper = new AesEncryptionHelper();

            //for test purposes, we're generating a new key each time
            AesEncryptionHelper.CipherKey = AesEncryptionHelper.GenerateCipherKey();
        }
Esempio n. 2
0
        public void Fail_To_Decrypt()
        {
            var plainText = "https://www.nsa.gov/";

            AesEncryptionHelper.CipherKey = null;

            var cipherText = _encryptionHelper.EncryptAsBase64(plainText);

            Assert.AreNotEqual(plainText, cipherText);

            AesEncryptionHelper.CipherKey = AesEncryptionHelper.GenerateCipherKey();//this will yield the wrong key that was used to encrypt

            Assert.Throws <CryptographicException>(() =>
            {
                var decryptedText = _encryptionHelper.DecryptAsBase64(cipherText);
            });
        }
Esempio n. 3
0
 public void Generate_Key()
 {
     var key = AesEncryptionHelper.GenerateCipherKey();
 }