Assuming that I am using this code to generate hashes:
static void Main(string[] args) {
string id = Guid.Parse("8681941A-76C2-4120-BC34-F800B5AAB5A5".ToLower()).ToString();
string date = DateTime.Today.ToString("yyyy-MM-dd");
Console.WriteLine(id);
Console.WriteLine(date);
using (System.Security.Cryptography.SHA512Managed hashTool =
new System.Security.Cryptography.SHA512Managed()) {
Byte[] PasswordAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(id, date));
Byte[] EncryptedBytes = hashTool.ComputeHash(PasswordAsByte);
hashTool.Clear();
Console.WriteLine(Convert.ToBase64String(EncryptedBytes));
}
Console.ReadLine();
}
In a real world example, I'll generate hashes with a GUID and Date as you see on the sample. I will get those values from database.
Is it ever possible to have the same hash result with different values with this approach?
Edit:
As I indicated I will pull the values form database. As you can guess, the Guid is the id key which is unique (if I do not come across a miracle and sql server generates the same Guid for me for multiple times). And the datetime value will be the payment due date for the record. I demonstrated here with DateTime.Today
but I won't definitely use this on prod.