using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
public static void Main(string[] args)
Console.WriteLine(TamperProofStringDecode("NjE5OQ==-rgrcZzTcPNo="));
public static string TamperProofStringDecode(string value)
string expectedEncryptedHashValue = string.Empty;
value = value.Replace(" ", "+");
System.Security.Cryptography.MACTripleDES mac3des = new System.Security.Cryptography.MACTripleDES();
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
mac3des.Key = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key));
string[] encryptedValues = value.Split('-');
if (encryptedValues.Length < 2)
dataValue = string.Empty;
dataValue = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(encryptedValues[0]));
Regex regex = new Regex(@"[^a-zA-Z0-9'{}[\]\\;':"",\./?!@#$%&*()_+=-`~\^\-|<> " + Convert.ToChar(124) + "]");
if (regex.Match(dataValue).Length > 0)
dataValue = string.Empty;
expectedEncryptedHashValue = Convert.ToBase64String(mac3des.ComputeHash(System.Text.Encoding.UTF8.GetBytes(dataValue)));
if (encryptedValues[1].IndexOf(expectedEncryptedHashValue) != 0)
dataValue = string.Empty;
dataValue = string.Empty;