Consider the following code:
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedBytes;
byte[] previousHashedBytes;
UTF8Encoding encoder = new UTF8Encoding();
// New hashedBytes array
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(someString + theValue));
// previousHashedBytes retrieved from DB
previousHashedBytes = GetPreviousValueFromDB();
The application then inserts hashedBytes into a database. I need to make sure due to a new policy that hashedBytes value cannot be reused, so I need some way to compare an existing hashedBytes value with a new one.
Note: the value for someString
is always the same.
How does one compare previousHashedBytes
with hashedBytes
to see if they are the same?