【AB加密】解密方法提交
parent
0bf844b8d8
commit
d154dc9248
|
@ -46,7 +46,8 @@ namespace GameLogic {
|
|||
string url = Util.DataPath + bundleName.ToLower();
|
||||
if (File.Exists(url))
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(url, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
//AssetBundle bundle = AssetBundle.LoadFromFile(url, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
AssetBundle bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(url), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
if (bundle != null)
|
||||
{
|
||||
bundleName = bundleName.Replace("lua/", "").Replace(".unity3d", "");
|
||||
|
|
|
@ -75,7 +75,8 @@ namespace GameLogic
|
|||
|
||||
public static int PIXELTOWORLD = 100;
|
||||
|
||||
public static ulong EncyptBytesLength = 128; // 资源加密空白字符长度,长度为0则不加密
|
||||
public static ulong EncyptBytesLength = 128; // 资源加密空白字符长度,长度为0则不加密
|
||||
public static string EncyptKey = ""; // 资源加密key值,空则不加密
|
||||
|
||||
#if UNITY_ANDROID
|
||||
public const string DOWNLOAD_URL_FORMAT = "{0}/Android/{1}/{2}{3}/";
|
||||
|
|
|
@ -85,6 +85,8 @@ namespace GameLogic
|
|||
if (File.Exists(VersionsFilePath))
|
||||
{
|
||||
VersionInfo = new Version(File.ReadAllText(VersionsFilePath, System.Text.Encoding.UTF8));
|
||||
// AB包加密key值
|
||||
AppConst.EncyptKey = VersionInfo.GetInfo("EncyptKey");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -96,6 +98,8 @@ namespace GameLogic
|
|||
{
|
||||
XDebug.Log.l("[VersionLoader OK ]=" + _www.text);
|
||||
VersionInfo = new Version(_www.text);
|
||||
// AB包加密key值
|
||||
AppConst.EncyptKey = VersionInfo.GetInfo("EncyptKey");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -369,8 +369,8 @@ namespace ResMgr
|
|||
#if XNCS
|
||||
XNCSUtils.BeginSample("LoadAssetBundle:{0}",path);
|
||||
#endif
|
||||
//assetBundle = AssetBundle.LoadFromMemory(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
assetBundle = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
assetBundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
//assetBundle = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
#if XNCS
|
||||
XNCSUtils.EndSample();
|
||||
#endif
|
||||
|
@ -398,8 +398,8 @@ namespace ResMgr
|
|||
{
|
||||
if (BaseLogger.isDebug) BaseLogger.LogFormat("<color=#00FF00>LoadAssetBundleAsyn:{0}</color>", path);
|
||||
abLoaderState = ABLoaderState.Loading;
|
||||
AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
//AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
//AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
AssetBundleCreateRequest request = AssetBundle.LoadFromMemoryAsync(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
while (!request.isDone)
|
||||
{
|
||||
progress = request.progress;
|
||||
|
|
|
@ -180,8 +180,8 @@ namespace ResMgr
|
|||
string path = string.Format("LZMA/ResConfigs").ToLower() + ResConfig.ABExtName;
|
||||
#endif
|
||||
string fullPath = PathHelper.GetFullPath (path);
|
||||
AssetBundle ab = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
//AssetBundle ab = AssetBundle.LoadFromMemory(XXTEA.Decrypt(File.ReadAllBytes(fullPath)));
|
||||
//AssetBundle ab = AssetBundle.LoadFromFile(fullPath, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
AssetBundle ab = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(fullPath), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
ResPathConfig = ab.LoadAsset<ResourcePathConfig>("ResourcePathConfig");
|
||||
ab.Unload(true);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,8 @@ public class GameStart : MonoBehaviour
|
|||
{
|
||||
path = AppConst.StreamPath + splashFilePath;
|
||||
}
|
||||
bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
//bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
GameObject gameObj = bundle.LoadAsset<GameObject>("SplashPanel");
|
||||
GameObject gameObj2 = Instantiate(gameObj, Vector3.zero, Quaternion.identity);
|
||||
Image image = gameObj2.transform.Find("Canvas/image").GetComponent<Image>();
|
||||
|
|
|
@ -125,7 +125,8 @@ namespace GameLogic {
|
|||
{
|
||||
path = AppConst.StreamPath + updateFilePath;
|
||||
}
|
||||
bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
//bundle = AssetBundle.LoadFromFile(path, 0, GameLogic.AppConst.EncyptBytesLength);
|
||||
bundle = AssetBundle.LoadFromMemory(GameLogic.MEncyptUtil.DecyptAB(File.ReadAllBytes(path), GameLogic.AppConst.EncyptKey, GameLogic.AppConst.EncyptBytesLength));
|
||||
if (bundle == null)
|
||||
{
|
||||
XDebug.Log.error(string.Format("{0} 不存在,请检查", path ));
|
||||
|
|
Loading…
Reference in New Issue