Exemplo n.º 1
0
        public static string Decrypt(string strCrypt)
        {
            if ((strCrypt.Length % 2 == 0))
            {
                AraCrypt ar = new AraCrypt();
                string sData = "";
                sData = ar.HexToBin(strCrypt);
                sData = ar.BinaryTransform("You're fired", sData);
                if (fieldCount(sData, '^') == 2)
                {
                    string sChecksum = fieldExtract(sData, 2, '^');
                    string sBase = fieldExtract(sData, 1, '^');
                    UInt32 cs = 0;
                    char[] szThisCs = new char[1000];
                    cs = Crc32Static.StringCrc32(sBase, ref cs);
                    string sCs = string.Format("{0:x}", cs);

                    if (sCs == sChecksum)
                    {
                        strCrypt = sBase;
                    }
                    else
                    {
                        throw new Exception("SPSStringTool experienced a type 1 failure.");
                    }
                }
            }
            return strCrypt;
        }
Exemplo n.º 2
0
 public static string Encrypt(string strCrypt)
 {
     UInt32 cs = 0;
     cs = Crc32Static.StringCrc32(strCrypt, ref cs);
     string sCs = string.Format("{0:x}", cs);
     string Merger = strCrypt + "^" + sCs;
     string sData = Merger;
     AraCrypt ar = new AraCrypt();
     sData = ar.BinaryTransform("You're fired", sData);
     string sDataHex = "";
     sDataHex = ar.BinToHex(sData);
     return sDataHex;
 }