obfuz/Samples/DynamicSecretKey/Assets/Bootstrap.cs

34 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Obfuz;
using Obfuz.EncryptionVM;
using UnityEngine;
public class Bootstrap : MonoBehaviour
{
[ObfuzIgnore]
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
private static void SetUpStaticSecretKey()
{
Debug.Log("SetUpStaticSecret begin");
EncryptionService<DefaultStaticEncryptionScope>.Encryptor = new GeneratedEncryptionVirtualMachine(Resources.Load<TextAsset>("Obfuz/defaultStaticSecretKey").bytes);
Debug.Log("SetUpStaticSecret end");
}
private static void SetUpDynamicSecret()
{
Debug.Log("SetUpDynamicSecret begin");
EncryptionService<DefaultDynamicEncryptionScope>.Encryptor = new GeneratedEncryptionVirtualMachine(Resources.Load<TextAsset>("Obfuz/defaultDynamicSecretKey").bytes);
Debug.Log("SetUpDynamicSecret end");
}
void Start()
{
// 延迟加载在使用HotUpdate程序集代码前才加载动态密钥。
// 如果项目用到了热更新,一般来说在热更新完成后,加载
// 热更新代码前才加载动态密钥。
SetUpDynamicSecret();
this.gameObject.AddComponent<Entry>();
}
}