i have the following piece of code. It has been working in my Staging and pre-production environments as well as in production.
How it has suddenly stopped working ONLY in the Production environment. It still works in pre-production and production.
It is throwing the "Hash value does not match" error meaning the storedHash != calcHash.
Any ideas why this might be happening in only of the 3 environments?
static public string StrDec(string value, string key)
{
String dataValue = "";
String calcHash = "";
String storedHash = "";
MACTripleDES mac3des = new MACTripleDES();
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
mac3des.Key = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
try
{
string strRemoveSpace = value.Replace(" ", "+");
dataValue = Encoding.UTF8.GetString(System.Convert.FromBase64String(strRemoveSpace.Split(System.Convert.ToChar("-"))[0]));
storedHash = Encoding.UTF8.GetString(System.Convert.FromBase64String(strRemoveSpace.Split(System.Convert.ToChar("-"))[1]));
calcHash = Encoding.UTF8.GetString(mac3des.ComputeHash(Encoding.UTF8.GetBytes(dataValue)));
if (storedHash != calcHash)
{
//Throw exception because data was corrupted here
throw new ArgumentException("Hash value does not match");
}
}
catch (System.Exception ex)
{
//Catch System.Exception here
}
return dataValue;
}