I have records in database that are plain text. From outside source I get md5 hash of string value.
Entities DB = ...
DB.SomeObjects.FirstOrDefault(p => p.PlainTextValue == md5HashedValue);
How can I convert this PlainTextValue to md5?
I have records in database that are plain text. From outside source I get md5 hash of string value.
Entities DB = ...
DB.SomeObjects.FirstOrDefault(p => p.PlainTextValue == md5HashedValue);
How can I convert this PlainTextValue to md5?
That's an awful implementation. To use it, you need to read all the rows from the DB, calculate its MD5 on the application side, and compare them with the provided value. That happens every time you execute this query. This is because the DB hasn't a way to do that calculation, and thus, the query cannot be converted into a SQL query. (In case it's not clear enough: you can only read all the texts from the DB, store them in a List or somewhere, and then, in the applicaiton side, calculate all of the hashes... every time)
The ideal solution would be to have the MD5 calculated on the DB, on a new column, or on a related table, to avoid repeating the calculations, and having to read and transfer all the texts to the application. (Then, whenever the text changes or a new text is inserted, calculate the hash, and store it in the DB).
To calculate an MD5 using C# you can look this SO Q&A.