File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ Obfuz的Unity Package Manager URL安装地址:
30
30
- 运行菜单` Obfuz/GenerateEncryptionVM ` 生成加密虚拟机代码,默认生成的代码文件为` Assets/Obfuz/GeneratedEncryptionVirtualMachine.cs ` 。
31
31
- 运行菜单` Obfuz/GenerateSecretKeyFile ` 生成两个密钥文件。默认输出文件为` Assets/Resources/Obfuz/defaultStaticSecretKey.bytes ` 和` Assets/Resources/Obfuz/defaultDynamicSecretKey.bytes `
32
32
33
+ ::: warning
34
+ 请妥善处理defaultStaticSecretKey.bytes和defaultDynamicSecretKey.bytes文件。建议更换名字,并且对它们都作加密处理。
35
+ 另外defaultDynamicSecretKey.bytes请尽量不要放到包体内,而是和热更新代码一起下载。
36
+ :::
37
+
33
38
## 添加代码
34
39
35
40
- 在` Assets ` 目录下创建` Bootstrap.cs ` 代码文件,文件内容如下:
Original file line number Diff line number Diff line change @@ -267,13 +267,17 @@ Obfuz通过EncryptionScope来实现这个功能。
267
267
268
268
菜单` Obfuz/GenerateSecretKey ` 会为这两个密钥生成defaultStaticSecretKey.bytes和defaultDynamicSecretKey.bytes文件。可在` SecretSettings.SecretKeyOutputPath ` 可以配置密钥文件的输出目录。
269
269
270
-
271
270
如果混淆了某些AOT程序集,由于AOT程序集中的代码在很早期就可能被执行到,如此不能在执行这些程序集中的混淆或者加密代码前就为它们所属的` EncryptionService<{EncryptionScope}> ` 设置Encryptor,
272
271
会产生运行异常。建议是尽可能早执行` EncryptionService<{EncryptionScope}>.Encrypor ` 的初始化代码。一个比较合理的方式是使用` [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] `
273
272
在CLR(il2cpp或mono)运行时加载完所有程序集后就运行EncryptionService的初始化代码。
274
273
275
274
显然,不应该混淆` SetUpStaticSecret ` 的代码,因为此时EncryptionService还未初始化,这会陷入无限递归。而` SetUpDynamicSecret ` 则可以被混淆,因此它一般在满足某些条件后(比如热更新完成后)才被调用。
276
275
276
+ ::: warning
277
+ 请妥善处理defaultStaticSecretKey.bytes和defaultDynamicSecretKey.bytes文件。建议更换名字,并且对它们都作加密处理。
278
+ 另外defaultDynamicSecretKey.bytes请尽量不要放到包体内,而是和热更新代码一起下载。
279
+ :::
280
+
277
281
## salt
278
282
279
283
Encryt或Decrypt中的salt是一个随机生成的参数,取值范围为` [int.MinValue, int.MaxValue] ` 。它作为一个额外的参数用于增加加密和解密操作的复杂性。
You can’t perform that action at this time.
0 commit comments