public void BasicEncryptAndDecrypt() { var u = new DBUser(); u.Username = "******"; var password = "******"; u.CreateCryptoFields(password); var test_string = "The quick brown fox jumps over the lazy dog."; var master_key = u.GetPlaintextMasterKey(password); byte[] encrypted_bytes = u.EncryptString(master_key, test_string); string decrypted_string = u.DecryptUnicodeString(master_key, encrypted_bytes); Assert.AreEqual(test_string, decrypted_string); }
public void EncryptDecryptWithHexRepresentation() { var u = new DBUser(); u.Username = "******"; var password = "******"; u.CreateCryptoFields(password); var master_key = u.GetPlaintextMasterKey(password); var key = master_key.ToHexString(); var test_string = "The quick brown fox jumps over the lazy dog."; byte[] encrypted_bytes = u.EncryptString(master_key, test_string); string encrypted_string = encrypted_bytes.ToHexString(); string decrypted_string = u.DecryptUnicodeString(master_key, encrypted_string.ToByteArray()); Assert.AreEqual(test_string, decrypted_string); }