private static string DecryptKey(string key) { byte[] bytes = Convert.FromBase64String(key); key = Encoding.UTF8.GetString(bytes, 0, bytes.Length); key = ObscuredString.EncryptDecrypt(key, encryptionKey); return(key); }
private static string EncryptKeyDeprecated(string key) { key = ObscuredString.EncryptDecrypt(key); if (lockToDevice != 0) { key = ObscuredString.EncryptDecrypt(key, GetDeviceIDDeprecated()); } key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); return(key); }
private static string EncryptKey(string key) { key = ObscuredString.EncryptDecrypt(key, encryptionKey); #if UNITY_FLASH key = Crypto.Base64Tools.ToBase64String(Encoding.UTF8.GetBytes(key)); #else key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); #endif return(key); }
private static string DecryptValueDeprecated(string value) { byte[] array = Convert.FromBase64String(value); value = Encoding.UTF8.GetString(array, 0, array.Length); if (lockToDevice != 0) { value = ObscuredString.EncryptDecrypt(value, GetDeviceIDDeprecated()); } value = ObscuredString.EncryptDecrypt(value, encryptionKey); return(value); }
private static string DecryptKey(string key) { #if UNITY_FLASH byte[] bytes = Crypto.Base64Tools.FromBase64String(key); #else byte[] bytes = Convert.FromBase64String(key); #endif key = Encoding.UTF8.GetString(bytes, 0, bytes.Length); key = ObscuredString.EncryptDecrypt(key, encryptionKey); return(key); }
private static string EncryptValue(string value) { string s = ObscuredString.EncryptDecrypt(value, encryptionKey); s = Convert.ToBase64String(Encoding.UTF8.GetBytes(s)); if (lockToDevice != 0) { string text = s; return(text + ':' + CalculateChecksum(s + DeviceHash) + ":" + DeviceHash); } return(s + ':' + CalculateChecksum(s)); }
private static string DecryptValueDeprecated(string value) { byte[] bytes = Convert.FromBase64String(value); value = Encoding.UTF8.GetString(bytes, 0, bytes.Length); if (lockToDevice != DeviceLockLevel.None) { value = ObscuredString.EncryptDecrypt(value, GetDeviceIDDeprecated()); } value = ObscuredString.EncryptDecrypt(value, encryptionKey); return(value); }
////////////////////////////////////////////////////// // methods for legacy PlayerPrefsObscured data reading ////////////////////////////////////////////////////// private static string EncryptKeyDeprecated(string key) { key = ObscuredString.EncryptDecrypt(key); #if !UNITY_FLASH if (lockToDevice != DeviceLockLevel.None) { key = ObscuredString.EncryptDecrypt(key, GetDeviceIDDeprecated()); } key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); #else key = Crypto.Base64Tools.ToBase64String(Encoding.UTF8.GetBytes(key)); #endif return(key); }
private string InternalDecrypt() { if (!this.inited) { this.currentCryptoKey = ObscuredString.cryptoKey; this.hiddenValue = ObscuredString.InternalEncrypt(""); this.inited = true; } string HDAJOEOLHGG = this.currentCryptoKey; if (string.IsNullOrEmpty(HDAJOEOLHGG)) { HDAJOEOLHGG = ObscuredString.cryptoKey; } return(ObscuredString.EncryptDecrypt(ObscuredString.GetString(this.hiddenValue), HDAJOEOLHGG)); }
private static string EncryptValue(string value, string key) { string encryptedValue = ObscuredString.EncryptDecrypt(value, encryptionKey); encryptedValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(encryptedValue)); if (lockToDevice != DeviceLockLevel.None) { encryptedValue += RAW_SEPARATOR + CalculateChecksum(encryptedValue + DeviceHash) + RAW_SEPARATOR + DeviceHash; } else { encryptedValue += RAW_SEPARATOR + CalculateChecksum(encryptedValue); } return(encryptedValue); }
private static string DecryptValueDeprecated(string value) { #if !UNITY_FLASH byte[] bytes = Convert.FromBase64String(value); value = Encoding.UTF8.GetString(bytes, 0, bytes.Length); #else value = Encoding.UTF8.GetString(Crypto.Base64Tools.FromBase64String(value)); #endif #if !UNITY_FLASH if (lockToDevice != DeviceLockLevel.None) { value = ObscuredString.EncryptDecrypt(value, GetDeviceIDDeprecated()); } #endif value = ObscuredString.EncryptDecrypt(value, encryptionKey); return(value); }
private static string EncryptValue(string value) { string encryptedValue = ObscuredString.EncryptDecrypt(value, encryptionKey); #if UNITY_FLASH encryptedValue = Crypto.Base64Tools.ToBase64String(Encoding.UTF8.GetBytes(encryptedValue)); encryptedValue += ":" + CalculateChecksum(encryptedValue); #else encryptedValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(encryptedValue)); if (lockToDevice != DeviceLockLevel.None) { encryptedValue += ':' + CalculateChecksum(encryptedValue + DeviceHash) + ":" + DeviceHash; } else { encryptedValue += ':' + CalculateChecksum(encryptedValue); } #endif return(encryptedValue); }
private string InternalDecrypt() { if (!this.inited) { this.currentCryptoKey = ObscuredString.cryptoKey; this.hiddenValue = ObscuredString.InternalEncrypt(string.Empty); this.fakeValue = string.Empty; this.inited = true; } string text = this.currentCryptoKey; if (string.IsNullOrEmpty(text)) { text = ObscuredString.cryptoKey; } string text2 = ObscuredString.EncryptDecrypt(ObscuredString.GetString(this.hiddenValue), text); if (ObscuredCheatingDetector.IsRunning && !string.IsNullOrEmpty(this.fakeValue) && text2 != this.fakeValue) { ObscuredCheatingDetector.Instance.OnCheatingDetected(); } return(text2); }
internal static string EncryptKey(string key) { key = ObscuredString.EncryptDecrypt(key, ObscuredPrefs.cryptoKey); key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); return(key); }
private static string EncryptKey(string key) { key = ObscuredString.EncryptDecrypt(key, encryptionKey); key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); return(key); }
private static string DecryptValue(string value) { string[] rawParts = value.Split(':'); if (rawParts.Length < 2) { SavesTampered(); return(""); } string b64EncryptedValue = rawParts[0]; string checksum = rawParts[1]; byte[] bytes; try { #if UNITY_FLASH bytes = Crypto.Base64Tools.FromBase64String(b64EncryptedValue); #else bytes = Convert.FromBase64String(b64EncryptedValue); #endif } catch { SavesTampered(); return(""); } string encryptedValue = Encoding.UTF8.GetString(bytes, 0, bytes.Length); string clearValue = ObscuredString.EncryptDecrypt(encryptedValue, encryptionKey); //return ((byte)clearValue[0]).ToString("X2") + ((byte)clearValue[1]).ToString("X2") + ((byte)clearValue[2]).ToString("X2"); //return clearValue; // checking saves for tamperation if (rawParts.Length == 3) { #if UNITY_FLASH SavesTampered(); #else if (checksum != CalculateChecksum(b64EncryptedValue + DeviceHash)) { SavesTampered(); } #endif } else if (rawParts.Length == 2) { if (checksum != CalculateChecksum(b64EncryptedValue)) { SavesTampered(); } } else { SavesTampered(); } #if !UNITY_FLASH // checking saves for foreignness if (lockToDevice != DeviceLockLevel.None && !emergencyMode) { if (rawParts.Length >= 3) { string deviceID = rawParts[2]; if (deviceID != DeviceHash) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } } else if (lockToDevice == DeviceLockLevel.Strict) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } else { if (checksum != CalculateChecksum(b64EncryptedValue)) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } } } #endif return(clearValue); }
private static string DecryptValue(string value) { string[] array = value.Split(':'); if (array.Length < 2) { SavesTampered(); return(string.Empty); } string text = array[0]; string a = array[1]; byte[] array2; try { array2 = Convert.FromBase64String(text); } catch { SavesTampered(); return(string.Empty); } string @string = Encoding.UTF8.GetString(array2, 0, array2.Length); string result = ObscuredString.EncryptDecrypt(@string, encryptionKey); if (array.Length == 3) { if (a != CalculateChecksum(text + DeviceHash)) { SavesTampered(); } } else if (array.Length == 2) { if (a != CalculateChecksum(text)) { SavesTampered(); } } else { SavesTampered(); } if (lockToDevice != 0 && !emergencyMode) { if (array.Length >= 3) { string a2 = array[2]; if (a2 != DeviceHash) { if (!readForeignSaves) { result = string.Empty; } PossibleForeignSavesDetected(); } } else if (lockToDevice == DeviceLockLevel.Strict) { if (!readForeignSaves) { result = string.Empty; } PossibleForeignSavesDetected(); } else if (a != CalculateChecksum(text)) { if (!readForeignSaves) { result = string.Empty; } PossibleForeignSavesDetected(); } } return(result); }
public static string EncryptDecrypt(string value) { return(ObscuredString.EncryptDecrypt(value, string.Empty)); }
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); }
private static string DecryptValue(string value, string key) { string[] rawParts = value.Split(RAW_SEPARATOR); if (rawParts.Length < 2) { SavesTampered(); return(""); } string b64EncryptedValue = rawParts[0]; string checksum = rawParts[1]; byte[] bytes; try { bytes = Convert.FromBase64String(b64EncryptedValue); } catch { SavesTampered(); return(""); } string encryptedValue = Encoding.UTF8.GetString(bytes, 0, bytes.Length); string clearValue = ObscuredString.EncryptDecrypt(encryptedValue, encryptionKey); // checking saves for tamperation if (rawParts.Length == 3) { if (checksum != CalculateChecksum(b64EncryptedValue + DeviceHash)) { SavesTampered(); } } else if (rawParts.Length == 2) { if (checksum != CalculateChecksum(b64EncryptedValue)) { SavesTampered(); } } else { SavesTampered(); } // checking saves for foreigness if (lockToDevice != DeviceLockLevel.None && !emergencyMode) { if (rawParts.Length >= 3) { string deviceID = rawParts[2]; if (deviceID != DeviceHash) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } } else if (lockToDevice == DeviceLockLevel.Strict) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } else { if (checksum != CalculateChecksum(b64EncryptedValue)) { if (!readForeignSaves) { clearValue = ""; } PossibleForeignSavesDetected(); } } } return(clearValue); }
private static byte[] InternalEncrypt(string PDGAOEAMDCL, string HDAJOEOLHGG) => ObscuredString.GetBytes(ObscuredString.EncryptDecrypt(PDGAOEAMDCL, HDAJOEOLHGG));
public static string EncryptDecrypt(string PDGAOEAMDCL) => ObscuredString.EncryptDecrypt(PDGAOEAMDCL, "");
private static byte[] InternalEncrypt(string value, string key) { return(ObscuredString.GetBytes(ObscuredString.EncryptDecrypt(value, key))); }
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); }