Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net Cryptography - is there a way to tell that something has been decrypted wrong?

See the title for question.

In a nut shell, what I am trying to do is encrypt some data with the seed (keyword) provided by the user. Is there a way to know that the data has been decrypted wrong, or in other words that the seed is wrong?

Using .net 2.0, C#

Thanks!

like image 903
sarsnake Avatar asked Dec 22 '22 22:12

sarsnake


1 Answers

It's quite normal to make a hash part of the encrypted data. Say, you have some data you want to encrypt. You then create an MD5 hash of this and add this to the end of the data. Then, when you decrypt it, you take the hash of the end of the encrypted data and verify that the hash hasn't changed.

like image 130
Pieter van Ginkel Avatar answered Feb 20 '23 21:02

Pieter van Ginkel