private static string DeprecatedDecryptValue(string value)
        {
            string[] array = value.Split(new char[]
            {
                ':'
            });
            if (array.Length < 2)
            {
                ObscuredPrefs.SavesTampered();
                return(string.Empty);
            }
            string text = array[0];
            string a    = array[1];

            byte[] array2;
            try
            {
                array2 = Convert.FromBase64String(text);
            }
            catch
            {
                ObscuredPrefs.SavesTampered();
                return(string.Empty);
            }
            string @string = Encoding.UTF8.GetString(array2, 0, array2.Length);
            string result  = ObscuredString.EncryptDecrypt(@string, ObscuredPrefs.cryptoKey);

            if (array.Length == 3)
            {
                if (a != ObscuredPrefs.DeprecatedCalculateChecksum(text + ObscuredPrefs.DeprecatedDeviceId))
                {
                    ObscuredPrefs.SavesTampered();
                }
            }
            else if (array.Length == 2)
            {
                if (a != ObscuredPrefs.DeprecatedCalculateChecksum(text))
                {
                    ObscuredPrefs.SavesTampered();
                }
            }
            else
            {
                ObscuredPrefs.SavesTampered();
            }
            if (ObscuredPrefs.lockToDevice != ObscuredPrefs.DeviceLockLevel.None && !ObscuredPrefs.emergencyMode)
            {
                if (array.Length >= 3)
                {
                    string a2 = array[2];
                    if (a2 != ObscuredPrefs.DeprecatedDeviceId)
                    {
                        if (!ObscuredPrefs.readForeignSaves)
                        {
                            result = string.Empty;
                        }
                        ObscuredPrefs.PossibleForeignSavesDetected();
                    }
                }
                else if (ObscuredPrefs.lockToDevice == ObscuredPrefs.DeviceLockLevel.Strict)
                {
                    if (!ObscuredPrefs.readForeignSaves)
                    {
                        result = string.Empty;
                    }
                    ObscuredPrefs.PossibleForeignSavesDetected();
                }
                else if (a != ObscuredPrefs.DeprecatedCalculateChecksum(text))
                {
                    if (!ObscuredPrefs.readForeignSaves)
                    {
                        result = string.Empty;
                    }
                    ObscuredPrefs.PossibleForeignSavesDetected();
                }
            }
            return(result);
        }
Exemple #2
0
        private static string DeprecatedDecryptValue(string value)
        {
            string[] strArray = value.Split(':');
            if (strArray.Length < 2)
            {
                ObscuredPrefs.SavesTampered();
                return(string.Empty);
            }
            string str1 = strArray[0];
            string str2 = strArray[1];

            byte[] bytes;
            try
            {
                bytes = Convert.FromBase64String(str1);
            }
            catch
            {
                ObscuredPrefs.SavesTampered();
                return(string.Empty);
            }
            string str3 = ObscuredString.EncryptDecrypt(Encoding.UTF8.GetString(bytes, 0, bytes.Length), ObscuredPrefs.encryptionKey);

            if (strArray.Length == 3)
            {
                if (str2 != ObscuredPrefs.DeprecatedCalculateChecksum(str1 + ObscuredPrefs.DeprecatedDeviceId))
                {
                    ObscuredPrefs.SavesTampered();
                }
            }
            else if (strArray.Length == 2)
            {
                if (str2 != ObscuredPrefs.DeprecatedCalculateChecksum(str1))
                {
                    ObscuredPrefs.SavesTampered();
                }
            }
            else
            {
                ObscuredPrefs.SavesTampered();
            }
            if (ObscuredPrefs.lockToDevice != ObscuredPrefs.DeviceLockLevel.None && !ObscuredPrefs.emergencyMode)
            {
                if (strArray.Length >= 3)
                {
                    if (strArray[2] != ObscuredPrefs.DeprecatedDeviceId)
                    {
                        if (!ObscuredPrefs.readForeignSaves)
                        {
                            str3 = string.Empty;
                        }
                        ObscuredPrefs.PossibleForeignSavesDetected();
                    }
                }
                else if (ObscuredPrefs.lockToDevice == ObscuredPrefs.DeviceLockLevel.Strict)
                {
                    if (!ObscuredPrefs.readForeignSaves)
                    {
                        str3 = string.Empty;
                    }
                    ObscuredPrefs.PossibleForeignSavesDetected();
                }
                else if (str2 != ObscuredPrefs.DeprecatedCalculateChecksum(str1))
                {
                    if (!ObscuredPrefs.readForeignSaves)
                    {
                        str3 = string.Empty;
                    }
                    ObscuredPrefs.PossibleForeignSavesDetected();
                }
            }
            return(str3);
        }