Exemplo n.º 1
0
        public static string[] DecryptHeaders(string data, string pass = "")
        {
            string[] strArray1          = new string[3];
            ushort   passCodeFromString = FileEncrypter.GetPassCodeFromString(pass);

            string[] strArray2 = data.Split(Utils.robustNewlineDelim, StringSplitOptions.RemoveEmptyEntries);
            if (strArray2.Length < 2)
            {
                throw new FormatException("Tried to decrypt an invalid valid DEC ENC file");
            }
            string[] strArray3 = strArray2[0].Split(FileEncrypter.HeaderSplitDelimiters, StringSplitOptions.None);
            if (strArray3.Length < 4)
            {
                throw new FormatException("Tried to decrypt an invalid valid DEC ENC file");
            }
            string str1 = FileEncrypter.Decrypt(strArray3[1], passCodeFromString);
            string str2 = FileEncrypter.Decrypt(strArray3[2], passCodeFromString);
            string str3 = (string)null;

            if (strArray3.Length > 4)
            {
                str3 = FileEncrypter.Decrypt(strArray3[4], passCodeFromString);
            }
            strArray1[0] = str1;
            strArray1[1] = str2;
            strArray1[2] = str3;
            return(strArray1);
        }
Exemplo n.º 2
0
        public static string[] DecryptString(string data, string pass = "")
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new NullReferenceException("String to decrypt cannot be null or empty");
            }
            string[] strArray1           = new string[6];
            ushort   passCodeFromString1 = FileEncrypter.GetPassCodeFromString(pass);
            ushort   passCodeFromString2 = FileEncrypter.GetPassCodeFromString("");

            string[] strArray2 = data.Split(Utils.robustNewlineDelim, StringSplitOptions.RemoveEmptyEntries);
            if (strArray2.Length < 2)
            {
                throw new FormatException("Tried to decrypt an invalid valid DEC ENC file \"" + data + "\" - not enough elements. Need 2 lines, had " + (object)strArray2.Length);
            }
            string[] strArray3 = strArray2[0].Split(FileEncrypter.HeaderSplitDelimiters, StringSplitOptions.None);
            if (strArray3.Length < 4)
            {
                throw new FormatException("Tried to decrypt an invalid valid DEC ENC file \"" + data + "\" - not enough headers");
            }
            string str1 = FileEncrypter.Decrypt(strArray3[1], passCodeFromString2);
            string str2 = FileEncrypter.Decrypt(strArray3[2], passCodeFromString2);
            string str3 = FileEncrypter.Decrypt(strArray3[3], passCodeFromString1);
            string str4 = (string)null;

            if (strArray3.Length > 4)
            {
                str4 = FileEncrypter.Decrypt(strArray3[4], passCodeFromString2);
            }
            string str5 = (string)null;
            string str6 = "1";

            if (str3 == "ENCODED")
            {
                str5 = FileEncrypter.Decrypt(strArray2[1], passCodeFromString1);
            }
            else
            {
                str6 = "0";
            }
            strArray1[0] = str1;
            strArray1[1] = str2;
            strArray1[2] = str5;
            strArray1[3] = str4;
            strArray1[4] = str6;
            strArray1[5] = str3;
            return(strArray1);
        }