public void TestEncrypt_empty() { var phe = new PheCrypto(); var rng = new SecureRandom(); var key = new byte[EncryptionService.SymKeyLen]; rng.NextBytes(key); var plainText = new byte[0]; var cipherText = phe.Encrypt(plainText, key); var decyptedText = phe.Decrypt(cipherText, key); Assert.Equal(decyptedText, plainText); }
public void TestEncrypt_badKey() { var phe = new PheCrypto(); var rng = new SecureRandom(); var key = new byte[EncryptionService.SymKeyLen]; rng.NextBytes(key); var plainText = new byte[365]; rng.NextBytes(plainText); var cipherText = phe.Encrypt(plainText, key); key[0]++; var ex = Record.Exception(() => { phe.Decrypt(cipherText, key); }); Assert.NotNull(ex); Assert.IsType <InvalidCipherTextException>(ex); }