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); }
public void RandomizeCryptoKey() { string PDGAOEAMDCL = this.InternalDecrypt(); this.currentCryptoKey = ""; this.hiddenValue = ObscuredString.InternalEncrypt(PDGAOEAMDCL, this.currentCryptoKey); }
public void RandomizeCryptoKey() { string str = this.InternalDecrypt(); this.currentCryptoKey = Random.get_seed().ToString(); this.hiddenValue = ObscuredString.InternalEncrypt(str, this.currentCryptoKey); }
public void UseObscured() { useRegular = false; obscuredString = "Hey, you can't change me in memory!"; cleanString = ""; Debug.Log("Try to change this string in memory:\n" + obscuredString); }
public void RandomizeCryptoKey() { string value = this.InternalDecrypt(); this.currentCryptoKey = UnityEngine.Random.Range(-2147483648, 2147483647).ToString(); this.hiddenValue = ObscuredString.InternalEncrypt(value, this.currentCryptoKey); }
public void UseRegular() { useRegular = true; cleanString = "Hey, you can easily change me in memory!"; obscuredString = ""; Debug.Log("Try to change this string in memory:\n" + cleanString); }
public void ApplyNewCryptoKey() { if (this.currentCryptoKey != ObscuredString.cryptoKey) { this.hiddenValue = ObscuredString.InternalEncrypt(this.InternalDecrypt()); this.currentCryptoKey = ObscuredString.cryptoKey; } }
public bool Equals(ObscuredString value, StringComparison comparisonType) { if (value == (ObscuredString)null) { return(false); } return(string.Equals(this.InternalDecrypt(), value.InternalDecrypt(), comparisonType)); }
public bool Equals(ObscuredString PDGAOEAMDCL) { if (PDGAOEAMDCL == (ObscuredString)null) { return(false); } return(this.currentCryptoKey == PDGAOEAMDCL.currentCryptoKey ? ObscuredString.ArraysEquals(this.hiddenValue, PDGAOEAMDCL.hiddenValue) : string.Equals(this.InternalDecrypt(), PDGAOEAMDCL.InternalDecrypt())); }
public void SetEncrypted(string encrypted) { this.inited = true; this.hiddenValue = ObscuredString.GetBytes(encrypted); if (ObscuredCheatingDetector.IsRunning) { this.fakeValue = this.InternalDecrypt(); } }
/// <summary> /// Determines whether this instance and another specified ObscuredString object have the same value. /// </summary> /// /// <returns> /// true if the value of the <paramref name="value"/> parameter is the same as this instance; otherwise, false. /// </returns> /// <param name="value">A ObscuredString. </param><filterpriority>2</filterpriority> public bool Equals(ObscuredString value) { byte[] a = null; if (value != null) { a = value.hiddenValue; } return(ArraysEquals(hiddenValue, a)); }
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); }
public bool Equals(ObscuredString value) { string b = null; if (value != null) { b = value.hiddenValue; } return(string.Equals(hiddenValue, b)); }
public bool Equals(ObscuredString value, StringComparison comparisonType) { string b = null; if (value != null) { b = value.InternalDecrypt(); } return(string.Equals(InternalDecrypt(), b, comparisonType)); }
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 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); }
public override bool Equals(object obj) { ObscuredString obscuredString = obj as ObscuredString; string b = null; if (obscuredString != null) { b = obscuredString.hiddenValue; } return(string.Equals(hiddenValue, b)); }
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); }
public bool Equals(ObscuredString value) { if (value == null) { return(false); } if (this.currentCryptoKey == value.currentCryptoKey) { return(ObscuredString.ArraysEquals(this.hiddenValue, value.hiddenValue)); } return(string.Equals(this.InternalDecrypt(), value.InternalDecrypt())); }
/// <summary> /// Determines whether this instance of ObscuredString and a specified object, which must also be a ObscuredString object, have the same value. /// </summary> /// /// <returns> /// true if <paramref name="obj"/> is a ObscuredString and its value is the same as this instance; otherwise, false. /// </returns> /// <param name="obj">An <see cref="T:System.Object"/>. </param><filterpriority>2</filterpriority> public override bool Equals(object obj) { ObscuredString strA = obj as ObscuredString; string strB = null; if (strA != null) { strB = GetString(strA.hiddenValue); } return(string.Equals(hiddenValue, strB)); }
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)); }
public static bool operator ==(ObscuredString IPJGCOBNHLB, ObscuredString IMMPDMOKFGC) { if ((object)IPJGCOBNHLB == (object)IMMPDMOKFGC) { return(true); } if ((object)IPJGCOBNHLB == null || (object)IMMPDMOKFGC == null) { return(false); } return(IPJGCOBNHLB.currentCryptoKey == IMMPDMOKFGC.currentCryptoKey ? ObscuredString.ArraysEquals(IPJGCOBNHLB.hiddenValue, IMMPDMOKFGC.hiddenValue) : string.Equals(IPJGCOBNHLB.InternalDecrypt(), IMMPDMOKFGC.InternalDecrypt())); }
void Start() { Screen.orientation = ScreenOrientation.Landscape; #region StatusInitialization lastScore = ObscuredPrefs.GetInt("LastScore"); highestScore = ObscuredPrefs.GetInt("HighestScore"); totalTime = (ObscuredPrefs.GetString("TotalTime") == "")? "00:00:000": ObscuredPrefs.GetString("TotalTime"); lastScoreHolder.text = "Last Score: " + lastScore.ToString(); highestScoreHolder.text = "Highest Score: " + highestScore.ToString(); totalTimeHolder.text = "Total Time: " + totalTime; #endregion }
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)); }
public static bool operator ==(ObscuredString a, ObscuredString b) { if (object.ReferenceEquals(a, b)) { return(true); } if (a == null || b == null) { return(false); } if (a.currentCryptoKey == b.currentCryptoKey) { return(ObscuredString.ArraysEquals(a.hiddenValue, b.hiddenValue)); } return(string.Equals(a.InternalDecrypt(), b.InternalDecrypt())); }
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 void Start() { Debug.Log("===== ObscuredStringTest =====\n"); // example of custom crypto key using // this is not necessary! default key is "4441" ObscuredString.SetNewCryptoKey("I LOVE MY GIRL"); // just a small self-test here (hey, Daniele! :D) cleanString = "Try Goscurry! Or better buy it!"; Debug.Log("Original string:\n" + cleanString); obscuredString = cleanString; Debug.Log("How your string is stored in memory when obscured:\n" + obscuredString.GetEncrypted()); obscuredString = cleanString = ""; }
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); }
public void SetMode() { if (isTF == true) { Mode = "TF"; AddCategories(Mode); } else if (isMCQs == true) { Mode = "MCQS"; AddCategories(Mode); } else if (isFIB == true) { Mode = "FIB"; AddCategories(Mode); } }
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); }
/// <summary> /// Determines whether this instance and another specified ObscuredString object have the same value. /// </summary> /// /// <returns> /// true if the value of the <paramref name="value"/> parameter is the same as this instance; otherwise, false. /// </returns> /// <param name="value">A ObscuredString. </param><filterpriority>2</filterpriority> public bool Equals(ObscuredString value) { byte[] a = null; if (value != null) a = value.hiddenValue; return ArraysEquals(hiddenValue, a); }
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 string EncryptKey(string key) { key = ObscuredString.EncryptDecrypt(key, encryptionKey); key = Convert.ToBase64String(Encoding.UTF8.GetBytes(key)); return(key); }
/// <summary> /// Determines whether this string and a specified ObscuredString object have the same value. A parameter specifies the culture, case, and sort rules used in the comparison. /// </summary> /// /// <returns> /// true if the value of the <paramref name="value"/> parameter is the same as this string; otherwise, false. /// </returns> /// <param name="value">An ObscuredString to compare.</param><param name="comparisonType">A value that defines the type of comparison. </param><exception cref="T:System.ArgumentException"><paramref name="comparisonType"/> is not a <see cref="T:System.StringComparison"/> value. </exception><filterpriority>2</filterpriority> public bool Equals(ObscuredString value, StringComparison comparisonType) { string strA = null; if (value != null) strA = value.InternalDecrypt(); return string.Equals(InternalDecrypt(), strA, comparisonType); }