private static bool CheckFileEntry(TamperDetectionFileEntry entry) { string[] files = Directory.GetFiles(entry.rootSearchPath, entry.filename, entry.mustBeExact ? SearchOption.TopDirectoryOnly : SearchOption.AllDirectories); if (files.Length == 0) { Debug.LogError(string.Format("File ({0}) not found in folder ({1})", entry.filename, entry.rootSearchPath)); return(false); } //Debug.Log(string.Format("File ({0}) found in folder ({1})", entry.filename, entry.rootSearchPath)); byte[] hash = _HashProvider.ComputeHash(File.OpenRead(files[0])); bool result = MixCastCryptoUtils.BytesEqual(hash, entry.hash); if (!result) { #if UNITY_EDITOR Debug.LogError(string.Format("hash mismatch: {0}, expected {1} got {2}", entry.filename, Convert.ToBase64String(entry.hash), Convert.ToBase64String(hash))); #else Debug.LogError("file change detected: " + files[0]); #endif } return(result); }
public static bool CheckFiles() { #if ENABLE_IL2CPP return(true); #else TamperDetectionFileEntry entry = new TamperDetectionFileEntry() { rootSearchPath = Application.dataPath, filename = "BouncyCastle.dll", hash = Convert.FromBase64String("tDGyqbczdzjiX4KT3wsHDIiQuVQ=") }; return(CheckFileEntry(entry)); #endif }