How to generate different hash values for same files/messages? I was generating HashValue for contents in the file. I want a different hash value every time I wanna generate even if the file is the same.
I am using SHA256. For the same files, the hash value I am getting is the same. Is there any way to generate different hash values?
You should use a cryptographic salt.
This is a single use number generated for each hash. The salt should be prepended to the file to be hashed before hashing. The salt and hash value can then be stored together. Now if you want to compare a file against a given hash you prepend the salt, hash and check against the stored value.
Provided that the salt values are unique, you should not get repeated values (subject to the birthday bound).