c# - How to prevent the encrypted (AES) data from being tampered with? -
i want encrypt data (aes) after saving database , decrypt when reading. how can prevent data being tampered in database? algorithm improved https://msdn.microsoft.com/en-us/library/system.security.cryptography.rijndaelmanaged(v=vs.110).aspx.
i have tested, in encrypted ciphertext casually add "a", decryption throw exception(the padding invalid , not removed), add charactor,will throw exception?there no such possibility: not throw exception, can decrypt, result not original data
string original = "getabedkk"; string password = "123456kfjseyr+*j"; string ciphertext = encrypt(original, password); messagebox.show("after encrypt:"+ciphertext); string plaintext = decrypt("a"+ciphertext, password); messagebox.show("after decrypt:" + plaintext);
add checksum or validation field. add layer encryption decrypts data, checks validation , throws exception if validation field not correct.
Comments
Post a Comment