public void ExpectValidDecryptionToSucceed() { var encryptionResult = SimpleAESEncryption.Encrypt(plaintext, password1); var decryptedText = SimpleAESEncryption.Decrypt(encryptionResult, password1); Assert.AreEqual(plaintext, decryptedText); }
public void ExpectEmptyInputsToProduceValidEncryption() { var encryptionResult = SimpleAESEncryption.Encrypt(string.Empty, string.Empty); Assert.IsTrue(!string.IsNullOrEmpty(encryptionResult.IV)); Assert.IsTrue(!string.IsNullOrEmpty(encryptionResult.EncryptedText)); }
public void ExpectValidEncryptionToSucceed() { var encryptionResult = SimpleAESEncryption.Encrypt(plaintext, password1); Assert.IsTrue(!string.IsNullOrEmpty(encryptionResult.EncryptedText)); Assert.AreNotEqual(plaintext, encryptionResult.EncryptedText); }
public override string GetJson() { var encrypted = SimpleAESEncryption.Encrypt(JsonUtility.ToJson(this), EncryptionKey); JSONNode rootNode = new JSONObject(); rootNode["json"] = encrypted.EncryptedText; rootNode["password"] = encrypted.IV; return(rootNode.ToString()); }
public void ExpectEmptyIVToFail() { var encryptionResult = SimpleAESEncryption.Encrypt(plaintext, password1); Assert.Throws <CryptographicException>(() => { SimpleAESEncryption.Decrypt(encryptionResult.EncryptedText, string.Empty, password1); }); }
public void ExpectWrongPasswordToFail() { var encryptionResult = SimpleAESEncryption.Encrypt(plaintext, password1); Assert.Throws <CryptographicException>(() => { SimpleAESEncryption.Decrypt(encryptionResult, password2); }); }
public void ExpectWrongIVToFail() { var encryptionResult = SimpleAESEncryption.Encrypt(plaintext, password1); var decryptedText = SimpleAESEncryption.Decrypt(encryptionResult.EncryptedText, exampleValidIV, password1); Assert.IsTrue(!string.IsNullOrEmpty(encryptionResult.EncryptedText)); Assert.AreNotEqual(plaintext, encryptionResult.EncryptedText); Assert.AreNotEqual(plaintext, decryptedText); }