【反破解】crash sight 和 BI Key 加密
parent
37ae0b0e74
commit
18cd3bc412
|
|
@ -9,6 +9,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Obfuz.Settings;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
|
@ -59,6 +60,31 @@ internal class BatchBuild
|
|||
/// </summary>
|
||||
private const string Release_PostUrl = "http://openapi.kedrgame.com/api/v1/";
|
||||
|
||||
private static void WriteEncryptedJsonResource(string resourceFileNameWithoutExtension, string json)
|
||||
{
|
||||
var resourcesPath = "Assets/Resources";
|
||||
var jsonPath = Path.Combine(resourcesPath, resourceFileNameWithoutExtension + ".json");
|
||||
var bytesPath = Path.Combine(resourcesPath, resourceFileNameWithoutExtension + ".bytes");
|
||||
|
||||
if (!Directory.Exists(resourcesPath))
|
||||
{
|
||||
Directory.CreateDirectory(resourcesPath);
|
||||
}
|
||||
|
||||
if (File.Exists(jsonPath))
|
||||
{
|
||||
File.Delete(jsonPath);
|
||||
var metaPath = jsonPath + ".meta";
|
||||
if (File.Exists(metaPath))
|
||||
{
|
||||
File.Delete(metaPath);
|
||||
}
|
||||
}
|
||||
|
||||
var encryptedBytes = LocalInfoEncrypt.Encrypt(Encoding.UTF8.GetBytes(json));
|
||||
File.WriteAllBytes(bytesPath, encryptedBytes);
|
||||
}
|
||||
|
||||
public static void _RevertScriptDefines()
|
||||
{
|
||||
var currentTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
|
||||
|
|
@ -690,9 +716,8 @@ internal class BatchBuild
|
|||
key = config.CrashSight_Android.Key
|
||||
};
|
||||
|
||||
var crashSightPath = "Assets/Resources/CrashSightData.json";
|
||||
var json = JsonUtility.ToJson(crashSightData);
|
||||
File.WriteAllText(crashSightPath, json);
|
||||
WriteEncryptedJsonResource("CrashSightData", json);
|
||||
Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key);
|
||||
}
|
||||
|
||||
|
|
@ -706,9 +731,8 @@ internal class BatchBuild
|
|||
key = config.CrashSight_iOS.Key
|
||||
};
|
||||
|
||||
var crashSightPath = "Assets/Resources/CrashSightData.json";
|
||||
var json = JsonUtility.ToJson(crashSightData);
|
||||
File.WriteAllText(crashSightPath, json);
|
||||
WriteEncryptedJsonResource("CrashSightData", json);
|
||||
Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key);
|
||||
}
|
||||
|
||||
|
|
@ -720,9 +744,8 @@ internal class BatchBuild
|
|||
channel = config.TalkingData.channel
|
||||
};
|
||||
|
||||
var talkingDataPath = "Assets/Resources/TalkingDataInitConfig.json";
|
||||
var json = JsonUtility.ToJson(talkingDataInitTool);
|
||||
File.WriteAllText(talkingDataPath, json);
|
||||
WriteEncryptedJsonResource("TalkingDataInitConfig", json);
|
||||
Debug.Log("TalkingData配置已保存:" + talkingDataInitTool.appID + "|" + talkingDataInitTool.channel);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 32e6eecf4e56684a4775c87c0e30a9c51ec403a2
|
||||
Subproject commit 5c492f8af5fa39a51a1ad8c21bc31c42755d286d
|
||||
|
|
@ -44,21 +44,12 @@ namespace PhxhSDK
|
|||
}
|
||||
|
||||
var appId = "";
|
||||
var loadJson = Resources.Load<TextAsset>("CrashSightData");
|
||||
if (loadJson == null)
|
||||
if (!EncryptedResourceLoader.TryLoadJson<CrashSightData>("CrashSightData", out var data))
|
||||
{
|
||||
DebugUtil.LogError("CrashSightSdkHelper", "CrashSightData.json not found");
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var data = JsonUtility.FromJson<CrashSightData>(loadJson.text);
|
||||
appId = data.id;
|
||||
} catch (Exception e)
|
||||
{
|
||||
DebugUtil.LogError("CrashSightSdkHelper" + "CrashSightData.json parse error: " + e.Message);
|
||||
DebugUtil.LogError("CrashSightSdkHelper", "CrashSightData resource load failed");
|
||||
return;
|
||||
}
|
||||
appId = data.id;
|
||||
if (!string.IsNullOrEmpty(appId))
|
||||
{
|
||||
CrashSightAgent.InitWithAppId(appId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue