{"id":183,"date":"2020-12-10T01:11:23","date_gmt":"2020-12-09T17:11:23","guid":{"rendered":"https:\/\/www.blinkedu.cn\/?p=183"},"modified":"2020-12-10T01:11:23","modified_gmt":"2020-12-09T17:11:23","slug":"unity%e4%b8%ad%e4%bd%bf%e7%94%a8aes%e5%8a%a0%e5%af%86%e6%96%b9%e5%bc%8f%e8%bf%9b%e8%a1%8cassetbundle%e5%8a%a0%e5%af%86","status":"publish","type":"post","link":"https:\/\/www.blinkedu.cn\/index.php\/2020\/12\/10\/unity%e4%b8%ad%e4%bd%bf%e7%94%a8aes%e5%8a%a0%e5%af%86%e6%96%b9%e5%bc%8f%e8%bf%9b%e8%a1%8cassetbundle%e5%8a%a0%e5%af%86\/","title":{"rendered":"Unity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6"},"content":{"rendered":"<h2>\u4e3a\u4ec0\u4e48\u8981\u5bf9AssetBundle\u8fdb\u884c\u52a0\u5bc6<\/h2>\n<p>\u9632\u6b62\u8d44\u6e90\u88ab\u7834\u89e3<\/p>\n<h2>\u52a0\u5bc6\u7b97\u6cd5<\/h2>\n<p>\u56e0\u4e3a\u5bf9AB\u5305\u8fdb\u884c\u52a0\u5bc6\u540e\u8fd8\u9700\u8981\u518d\u52a0\u8f7dAB\u5305\u65f6\u8fdb\u884c\u89e3\u5bc6\uff0c\u6240\u4ee5\u9009\u62e9AES\u52a0\u5bc6\u65b9\u5f0f\u3002AES\u662f\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u5728\u52a0\u5bc6\u65f6\u4f1a\u8bbe\u5b9a\u4e00\u4e2a\u5bc6\u94a5\uff0c\u901a\u8fc7\u8be5\u5bc6\u94a5\u8fdb\u884c\u52a0\u5bc6\u3002\u5728\u6e38\u620f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u52a0\u8f7dAB\u5305\u65f6\uff0c\u5148\u4f7f\u7528\u540c\u6837\u7684\u5bc6\u94a5\u5bf9\u5176\u8fdb\u884c\u89e3\u5bc6\uff0c\u7136\u540e\u518d\u52a0\u8f7dAB\u5305\u3002<\/p>\n<ul>\n<li>\u4e3a\u4e86\u8bc6\u522b\u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u88ab\u52a0\u5bc6\u8fc7\uff08\u9632\u6b62\u591a\u6b21\u52a0\u5bc6\uff09\u3002\u9700\u8981\u5b9a\u4e00\u4e2a\u6587\u4ef6\u7684\u8bc6\u522b\u5934\uff08\u8fd9\u91cc\u8bbe\u7f6e\u7684&#8221;AESEncrypt&#8221;\uff09\uff0c\u5728\u52a0\u5bc6\u65f6\u4f1a\u5c06\u8fd9\u4e2a\u5934\u5199\u5165\u5230\u6587\u4ef6\u7684\u5934\u90e8\uff0c\u5f53\u52a0\u5bc6\u65f6\u8bfb\u53d6\u6700\u524d\u9762\u7684\u548c\u8bc6\u522b\u5934\u76f8\u7b49\u957f\u5ea6\u7684\u5b57\u8282\u4e0e\u8bc6\u522b\u5934\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u76f8\u7b49\u5219\u8868\u793a\u52a0\u5bc6\u8fc7\uff0c\u5426\u5219\u5c31\u8fdb\u884c\u52a0\u5bc6\u3002<\/li>\n<li>\u8fdb\u884c\u89e3\u5bc6\u65f6\uff0c\u9700\u8981\u5c06\u8bc6\u522b\u5b57\u8282\u5934\u7ed9\u79fb\u9664\u518d\u8fdb\u884c\u89e3\u5bc6<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u662f\u8fdb\u884cAES\u52a0\u5bc6\u7684\u811a\u672c\u4ee3\u7801\uff0c\u5177\u4f53\u539f\u7406\u7f51\u4e0a\u6709\u5f88\u591a\u8bb2\u89e3\uff08\u6211\u4e5f\u662f\u642c\u8fd0\u8fc7\u6765\u7684 2333333&#8230;\uff09<\/p>\n<pre><code class=\"language-csharp line-numbers\">using System;\nusing System.IO;\nusing System.Security.Cryptography;\nusing System.Text;\nusing UnityEngine;\npublic class AES\n{\n    \/\/ \u52a0\u5bc6\u8bc6\u522b\u5934\uff08\u7528\u6765\u8bc6\u522b\u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u52a0\u5bc6\u8fc7\uff09\n    private const string AES_HEAD = &quot;AESEncrypt&quot;;\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ \u6587\u4ef6\u52a0\u5bc6\uff0c\u4f20\u5165\u6587\u4ef6\u8def\u5f84\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;path&quot;&gt;&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;EncrptyKey&quot;&gt;&lt;\/param&gt;\n    public static void AESFileEncrypt(string path, string EncrptyKey)\n    {\n        if (!File.Exists(path))\n            return;\n        try\n        {\n            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))\n            {\n                if (fs != null)\n                {\n                    \/\/\u8bfb\u53d6\u5b57\u8282\u5934\uff0c\u5224\u65ad\u662f\u5426\u5df2\u7ecf\u52a0\u5bc6\u8fc7\u4e86\n                    byte[] headBuff = new byte[10];\n                    fs.Read(headBuff, 0, headBuff.Length);\n                    string headTag = Encoding.UTF8.GetString(headBuff);\n                    if (headTag == AES_HEAD)\n                    {\n#if UNITY_EDITOR\n                        Debug.Log(path + &quot;\u5df2\u7ecf\u52a0\u5bc6\u8fc7\u4e86\uff01&quot;);\n#endif\n                        return;\n                    }\n                    \/\/\u52a0\u5bc6\u5e76\u4e14\u5199\u5165\u5b57\u8282\u5934\n                    fs.Seek(0, SeekOrigin.Begin);\n                    byte[] buffer = new byte[fs.Length];\n                    fs.Read(buffer, 0, Convert.ToInt32(fs.Length));\n                    fs.Seek(0, SeekOrigin.Begin);\n                    fs.SetLength(0);\n                    byte[] headBuffer = Encoding.UTF8.GetBytes(AES_HEAD);\n                    fs.Write(headBuffer, 0, headBuffer.Length);\n                    byte[] EncBuffer = AESEncrypt(buffer, EncrptyKey);\n                    fs.Write(EncBuffer, 0, EncBuffer.Length);\n                }\n            }\n        }\n        catch (Exception e)\n        {\n            Debug.LogError(e);\n        }\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ \u6587\u4ef6\u89e3\u5bc6\uff0c\u4f20\u5165\u6587\u4ef6\u8def\u5f84\uff08\u4f1a\u6539\u52a8\u52a0\u5bc6\u6587\u4ef6\uff0c\u4e0d\u9002\u5408\u8fd0\u884c\u65f6\uff09\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;path&quot;&gt;&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;EncrptyKey&quot;&gt;&lt;\/param&gt;\n    public static void AESFileDecrypt(string path, string EncrptyKey)\n    {\n        if (!File.Exists(path))\n        {\n            return;\n        }\n        try\n        {\n            using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite))\n            {\n                if (fs != null)\n                {\n                    byte[] headBuff = new byte[10];\n                    fs.Read(headBuff, 0, headBuff.Length);\n                    string headTag = Encoding.UTF8.GetString(headBuff);\n                    if (headTag == AES_HEAD)\n                    {\n                        byte[] buffer = new byte[fs.Length - headBuff.Length];\n                        fs.Read(buffer, 0, Convert.ToInt32(fs.Length - headBuff.Length));\n                        fs.Seek(0, SeekOrigin.Begin);\n                        fs.SetLength(0);\n                        byte[] DecBuffer = AESDecrypt(buffer, EncrptyKey);\n                        fs.Write(DecBuffer, 0, DecBuffer.Length);\n                    }\n                }\n            }\n        }\n        catch (Exception e)\n        {\n            Debug.LogError(e);\n        }\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ \u6587\u4ef6\u89e3\u5bc6\uff0c\u4f20\u5165\u6587\u4ef6\u8def\u5f84\uff0c\u8fd4\u56de\u5b57\u8282\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;returns&gt;&lt;\/returns&gt;\n    public static byte[] AESFileByteDecrypt(string path, string EncrptyKey)\n    {\n        if (!File.Exists(path))\n        {\n            return null;\n        }\n        byte[] DecBuffer = null;\n        try\n        {\n            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))\n            {\n                if (fs != null)\n                {\n                    byte[] headBuff = new byte[10];\n                    fs.Read(headBuff, 0, headBuff.Length);\n                    string headTag = Encoding.UTF8.GetString(headBuff);\n                    if (headTag == AES_HEAD)\n                    {\n                        byte[] buffer = new byte[fs.Length - headBuff.Length];\n                        fs.Read(buffer, 0, Convert.ToInt32(fs.Length - headBuff.Length));\n                        DecBuffer = AESDecrypt(buffer, EncrptyKey);\n                    }\n                }\n            }\n        }\n        catch (Exception e)\n        {\n            Debug.LogError(e);\n        }\n\n        return DecBuffer;\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ AES \u52a0\u5bc6(\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6\uff0c\u662f\u4e0b\u4e00\u4ee3\u7684\u52a0\u5bc6\u7b97\u6cd5\u6807\u51c6\uff0c\u901f\u5ea6\u5feb\uff0c\u5b89\u5168\u7ea7\u522b\u9ad8\uff0c\u76ee\u524d AES \u6807\u51c6\u7684\u4e00\u4e2a\u5b9e\u73b0\u662f Rijndael \u7b97\u6cd5)\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;EncryptString&quot;&gt;\u5f85\u52a0\u5bc6\u5bc6\u6587&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;EncryptKey&quot;&gt;\u52a0\u5bc6\u5bc6\u94a5&lt;\/param&gt;\n    public static string AESEncrypt(string EncryptString, string EncryptKey)\n    {\n        return Convert.ToBase64String(AESEncrypt(Encoding.Default.GetBytes(EncryptString), EncryptKey));\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ AES \u52a0\u5bc6(\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6\uff0c\u662f\u4e0b\u4e00\u4ee3\u7684\u52a0\u5bc6\u7b97\u6cd5\u6807\u51c6\uff0c\u901f\u5ea6\u5feb\uff0c\u5b89\u5168\u7ea7\u522b\u9ad8\uff0c\u76ee\u524d AES \u6807\u51c6\u7684\u4e00\u4e2a\u5b9e\u73b0\u662f Rijndael \u7b97\u6cd5)\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;EncryptString&quot;&gt;\u5f85\u52a0\u5bc6\u5bc6\u6587&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;EncryptKey&quot;&gt;\u52a0\u5bc6\u5bc6\u94a5&lt;\/param&gt;\n    public static byte[] AESEncrypt(byte[] EncryptByte, string EncryptKey)\n    {\n        if (EncryptByte.Length == 0) { throw (new Exception(&quot;\u660e\u6587\u4e0d\u5f97\u4e3a\u7a7a&quot;)); }\n        if (string.IsNullOrEmpty(EncryptKey)) { throw (new Exception(&quot;\u5bc6\u94a5\u4e0d\u5f97\u4e3a\u7a7a&quot;)); }\n        byte[] m_strEncrypt;\n        byte[] m_btIV = Convert.FromBase64String(&quot;Rkb4jvUy\/ye7Cd7k89QQgQ==&quot;);\n        byte[] m_salt = Convert.FromBase64String(&quot;gsf4jvkyhye5\/d7k8OrLgM==&quot;);\n        Rijndael m_AESProvider = Rijndael.Create();\n        try\n        {\n            MemoryStream m_stream = new MemoryStream();\n            PasswordDeriveBytes pdb = new PasswordDeriveBytes(EncryptKey, m_salt);\n            ICryptoTransform transform = m_AESProvider.CreateEncryptor(pdb.GetBytes(32), m_btIV);\n            CryptoStream m_csstream = new CryptoStream(m_stream, transform, CryptoStreamMode.Write);\n            m_csstream.Write(EncryptByte, 0, EncryptByte.Length);\n            m_csstream.FlushFinalBlock();\n            m_strEncrypt = m_stream.ToArray();\n            m_stream.Close(); m_stream.Dispose();\n            m_csstream.Close(); m_csstream.Dispose();\n        }\n        catch (IOException ex) { throw ex; }\n        catch (CryptographicException ex) { throw ex; }\n        catch (ArgumentException ex) { throw ex; }\n        catch (Exception ex) { throw ex; }\n        finally { m_AESProvider.Clear(); }\n        return m_strEncrypt;\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ AES \u89e3\u5bc6(\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6\uff0c\u662f\u4e0b\u4e00\u4ee3\u7684\u52a0\u5bc6\u7b97\u6cd5\u6807\u51c6\uff0c\u901f\u5ea6\u5feb\uff0c\u5b89\u5168\u7ea7\u522b\u9ad8\uff0c\u76ee\u524d AES \u6807\u51c6\u7684\u4e00\u4e2a\u5b9e\u73b0\u662f Rijndael \u7b97\u6cd5)\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;DecryptString&quot;&gt;\u5f85\u89e3\u5bc6\u5bc6\u6587&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;DecryptKey&quot;&gt;\u89e3\u5bc6\u5bc6\u94a5&lt;\/param&gt;\n    public static string AESDecrypt(string DecryptString, string DecryptKey)\n    {\n        return Convert.ToBase64String(AESDecrypt(Encoding.Default.GetBytes(DecryptString), DecryptKey));\n    }\n\n    \/\/\/ &lt;summary&gt;\n    \/\/\/ AES \u89e3\u5bc6(\u9ad8\u7ea7\u52a0\u5bc6\u6807\u51c6\uff0c\u662f\u4e0b\u4e00\u4ee3\u7684\u52a0\u5bc6\u7b97\u6cd5\u6807\u51c6\uff0c\u901f\u5ea6\u5feb\uff0c\u5b89\u5168\u7ea7\u522b\u9ad8\uff0c\u76ee\u524d AES \u6807\u51c6\u7684\u4e00\u4e2a\u5b9e\u73b0\u662f Rijndael \u7b97\u6cd5)\n    \/\/\/ &lt;\/summary&gt;\n    \/\/\/ &lt;param name=&quot;DecryptString&quot;&gt;\u5f85\u89e3\u5bc6\u5bc6\u6587&lt;\/param&gt;\n    \/\/\/ &lt;param name=&quot;DecryptKey&quot;&gt;\u89e3\u5bc6\u5bc6\u94a5&lt;\/param&gt;\n    public static byte[] AESDecrypt(byte[] DecryptByte, string DecryptKey)\n    {\n        if (DecryptByte.Length == 0) { throw (new Exception(&quot;\u5bc6\u6587\u4e0d\u5f97\u4e3a\u7a7a&quot;)); }\n        if (string.IsNullOrEmpty(DecryptKey)) { throw (new Exception(&quot;\u5bc6\u94a5\u4e0d\u5f97\u4e3a\u7a7a&quot;)); }\n        byte[] m_strDecrypt;\n        byte[] m_btIV = Convert.FromBase64String(&quot;Rkb4jvUy\/ye7Cd7k89QQgQ==&quot;);\n        byte[] m_salt = Convert.FromBase64String(&quot;gsf4jvkyhye5\/d7k8OrLgM==&quot;);\n        Rijndael m_AESProvider = Rijndael.Create();\n        try\n        {\n            MemoryStream m_stream = new MemoryStream();\n            PasswordDeriveBytes pdb = new PasswordDeriveBytes(DecryptKey, m_salt);\n            ICryptoTransform transform = m_AESProvider.CreateDecryptor(pdb.GetBytes(32), m_btIV);\n            CryptoStream m_csstream = new CryptoStream(m_stream, transform, CryptoStreamMode.Write);\n            m_csstream.Write(DecryptByte, 0, DecryptByte.Length);\n            m_csstream.FlushFinalBlock();\n            m_strDecrypt = m_stream.ToArray();\n            m_stream.Close(); m_stream.Dispose();\n            m_csstream.Close(); m_csstream.Dispose();\n        }\n        catch (IOException ex) { throw ex; }\n        catch (CryptographicException ex) { throw ex; }\n        catch (ArgumentException ex) { throw ex; }\n        catch (Exception ex) { throw ex; }\n        finally { m_AESProvider.Clear(); }\n        return m_strDecrypt;\n    }\n}\n\n<\/code><\/pre>\n<h2>\u6253\u5305AssetBundle<\/h2>\n<p>\u9996\u5148\u642d\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u754c\u9762\uff0c\u5c06\u5176\u5236\u4f5c\u6210\u9884\u5236\u4f53<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_31648904479e0130ed96048dd2d4f1dd.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_31648904479e0130ed96048dd2d4f1dd.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_31648904479e0130ed96048dd2d4f1dd.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><br \/>\n\u63a5\u4e0b\u6765\u9700\u8981\u8bbe\u7f6e\u9884\u5236\u4f53\u7684AssetBundle\u540d\u79f0<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_9c7b642bab093e0dfe987af44a426e17.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_9c7b642bab093e0dfe987af44a426e17.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_9c7b642bab093e0dfe987af44a426e17.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<p>\u7f16\u5199\u6253\u5305\u7684\u811a\u672c\u4ee3\u7801\uff08\u8be5\u811a\u672c\u9700\u8981\u653e\u7f6e\u5728Editor\u76ee\u5f55\u4e0b\uff09\uff0c\u811a\u672c\u540d\u79f0\u968f\u610f\uff0c\u8fd9\u91cc\u5c31\u53ea\u8d34\u51fa\u6253\u5305\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"language-csharp line-numbers\">  [MenuItem(&quot;Tools\/Build&quot;)]\n    static void Build()\n    {\n        string path = Application.streamingAssetsPath + &quot;\/&quot; + EditorUserBuildSettings.activeBuildTarget;\n        if (!Directory.Exists(path))\n        {\n            Directory.CreateDirectory(path);\n        }\n        BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.ChunkBasedCompression, EditorUserBuildSettings.activeBuildTarget);\n        AssetDatabase.Refresh();\n    }\n<\/code><\/pre>\n<p>\u7b49Unity\u7f16\u8bd1\u5b8c\u540e\u518d\u9876\u90e8\u83dc\u5355\u4e2d\u4f1a\u51fa\u73b0Tools\u9009\u9879\uff0c\u70b9\u51fb\u4e0b\u65b9\u7684Build\u8fdb\u884c\u6253\u5305<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_475fd66b24cfb48ee5e104d7ce5c9fa3.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_475fd66b24cfb48ee5e104d7ce5c9fa3.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_475fd66b24cfb48ee5e104d7ce5c9fa3.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<p>\u6253\u5305\u5b8c\u7684AssetBundle<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_44b93b8e5f5e4f3a7bf838a6ac587220.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_44b93b8e5f5e4f3a7bf838a6ac587220.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_44b93b8e5f5e4f3a7bf838a6ac587220.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<p>\u5c1d\u8bd5\u7528\u4f7f\u7528AssetStudio\u67e5\u770b\u4e00\u4e0bab\u5305\uff0c\u5c06panel\u62d6\u5165AssetStudio\u4e2d\uff0c\u6210\u529f\u770b\u5230\u6253\u5305\u5230ab\u5305\u4e2d\u7684\u56fe\u7247<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_ae239568a4c103f8883108abde169b00.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_ae239568a4c103f8883108abde169b00.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_ae239568a4c103f8883108abde169b00.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<h2>\u52a0\u5bc6AssetBundle<\/h2>\n<p>\u540c\u6253\u5305\u4e00\u6837\uff0c\u5728\u6253\u5305\u7684\u811a\u672c\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u52a0\u5bc6\u65b9\u6cd5\u8fdb\u884c\u6d4b\u8bd5\uff0c\u70b9\u51fb\u83dc\u5355\u4e2d\u7684\u52a0\u5bc6<\/p>\n<pre><code class=\"language-csharp line-numbers\">[MenuItem(&quot;Tools\/\u52a0\u5bc6&quot;)]\n    static void EncryptAssetBundle()\n    {\n        string path = Application.streamingAssetsPath + &quot;\/&quot; + EditorUserBuildSettings.activeBuildTarget + &quot;\/panel&quot;;\n        AES.AESFileEncrypt(path, SECRET_KEY);\n        AssetDatabase.Refresh();\n    }\n<\/code><\/pre>\n<p>\u7528\u8bb0\u4e8b\u672c\u6253\u5f00panel\uff0c\u53d1\u73b0\u524d\u9762\u51fa\u73b0\u4e86\u6807\u8bc6\u5934AESEncrypt<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_589309b57eb978fd0e294a9a6299cd9e.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_589309b57eb978fd0e294a9a6299cd9e.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_589309b57eb978fd0e294a9a6299cd9e.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<p>\u518d\u7528AssteStudio\u770b\u4e00\u4e0b\u80fd\u4e0d\u80fd\u67e5\u770b\u5230\u91cc\u9762\u7684\u8d44\u6e90\uff0c\u7ed3\u679c\u662f\u7a7a\u7a7a\u5982\u4e5f\uff0c\u6ca1\u6709\u4efb\u4f55\u5185\u5bb9<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_7afb1f6405b296e4545d45f79290c40f.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_7afb1f6405b296e4545d45f79290c40f.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_7afb1f6405b296e4545d45f79290c40f.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n<h2>\u89e3\u5bc6\u548c\u52a0\u8f7dAB\u5305<\/h2>\n<p>\u540c\u4e0a\u4e00\u6837\uff0c\u5199\u4e00\u4e2a\u65b9\u6cd5\u6d4b\u8bd5\u4e00\u4e0b\u5bf9AB\u5305\u8fdb\u884c\u89e3\u5bc6\uff0c\u5e76\u5c06\u754c\u9762\u5b9e\u529b\u5316\u51fa\u6765<\/p>\n<pre><code class=\"language-csharp line-numbers\">[MenuItem(&quot;Tools\/\u89e3\u5bc6&quot;)]\n    static void DecryptAssetBunld()\n    {\n        string path = Application.streamingAssetsPath + &quot;\/&quot; + EditorUserBuildSettings.activeBuildTarget + &quot;\/panel&quot;;\n        \/\/ \u5bf9AB\u5305\u8fdb\u884c\u89e3\u5bc6\n        byte[] bytes = AES.AESFileByteDecrypt(path, SECRET_KEY);\n        \/\/ \u4ece\u5185\u5b58\u4e2d\u52a0\u8f7dAB\u5305\n        AssetBundle ab = AssetBundle.LoadFromMemory(bytes);\n        \/\/ \u52a0\u8f7dAB\u5305\u4e2d\u7684\u540d\u5b57\u4e3aPanel\u9884\u5236\u4f53\n        GameObject prefab = ab.LoadAsset&lt;GameObject&gt;(&quot;Panel&quot;);\n        \/\/ \u5b9e\u4f8b\u5316\u9884\u5236\u4f53\u5230Canvas\u4e0b\n        GameObject.Instantiate(prefab,GameObject.Find(&quot;Canvas&quot;).transform);\n    }\n<\/code><\/pre>\n<p>\u70b9\u51fbTools\u83dc\u5355\u4e0b\u7684\u89e3\u5bc6\uff0c\u6210\u529f\u5b9e\u4f8b\u5316\u754c\u9762<br \/>\n<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_87b4dc5b8040965b8bf9d212c6abc8a8.jpg\"><img decoding=\"async\" layer-src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_87b4dc5b8040965b8bf9d212c6abc8a8.jpg\" src=\"https:\/\/www.blinkedu.cn\/wp-content\/uploads\/2020\/12\/wp_editor_md_87b4dc5b8040965b8bf9d212c6abc8a8.jpg\" alt=\"\u300aUnity\u4e2d\u4f7f\u7528AES\u52a0\u5bc6\u65b9\u5f0f\u8fdb\u884cAssetBundle\u52a0\u5bc6\u300b\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u8981\u5bf9AssetBundle\u8fdb\u884c\u52a0\u5bc6 \u9632\u6b62\u8d44\u6e90\u88ab\u7834\u89e3 \u52a0\u5bc6\u7b97\u6cd5 \u56e0\u4e3a\u5bf9AB\u5305\u8fdb\u884c\u52a0\u5bc6\u540e\u8fd8\u9700\u8981\u518d\u52a0\u8f7dAB\u5305\u65f6\u8fdb\u884c\u89e3\u5bc6\uff0c\u6240\u4ee5\u9009\u62e9AES\u52a0\u5bc6\u65b9\u5f0f\u3002AES\u662f\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u5728\u52a0\u5bc6\u65f6\u4f1a\u8bbe\u5b9a\u4e00\u4e2a\u5bc6\u94a5\uff0c\u901a\u8fc7\u8be5\u5bc6\u94a5\u8fdb\u884c\u52a0\u5bc6\u3002\u5728\u6e38\u620f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u52a0\u8f7dAB\u5305\u65f6\uff0c\u5148\u4f7f\u7528\u540c\u6837\u7684\u5bc6\u94a5\u5bf9\u5176\u8fdb\u884c\u89e3\u5bc6\uff0c\u7136\u540e\u518d\u52a0\u8f7dAB\u5305\u3002 \u4e3a\u4e86\u8bc6\u522b\u6587\u4ef6\u662f\u5426\u5df2\u7ecf\u88ab\u52a0\u5bc6\u8fc7\uff08\u9632\u6b62\u591a\u6b21\u52a0\u5bc6\uff09\u3002\u9700\u8981\u2026\u2026<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-unity"],"_links":{"self":[{"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/posts\/183"}],"collection":[{"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":0,"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blinkedu.cn\/index.php\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}