public static string buildHash(string sDado, string funcao)
int [] vChave= {121, 211, 111, 90, 122, 13, 14, 15};
for (int n2= 0; n2 < sDado.Length; n2++) {
int code= (int)sDado[n2] ^ vChave[n];
string hcode= (code.ToString("X")).PadLeft(2,'0');
if (n < (vChave.Length-1)) n++; else n = 0;
sRetorno = sRetorno + hcode;
sRetorno = "$" + sRetorno.ToUpper();
sDado=sDado.Substring(1,sDado.Length-1);
for (int n2= 0; n2 < sDado.Length; n2=n2+2) {
int intValue = int.Parse(sDado.Substring(n2,2), System.Globalization.NumberStyles.HexNumber) ^ vChave[n];
if (n < (vChave.Length-1)) n++; else n = 0;
sRetorno = sRetorno + (char)intValue;
public static void Main()
Console.WriteLine(buildHash("Teste de criptografia","cryptar"));
Console.WriteLine(buildHash("$2DB61C2E1F2D6A6A59B01D330A7961680BB209331B","decryptar"));