2025-05-11 19:28:19 +08:00
|
|
|
using Obfuz.EncryptionVM;
|
|
|
|
using Obfuz.Settings;
|
2025-05-12 08:13:01 +08:00
|
|
|
using Obfuz.Utils;
|
|
|
|
using System.IO;
|
2025-04-16 23:03:41 +08:00
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
2025-05-12 08:13:01 +08:00
|
|
|
using FileUtil = Obfuz.Utils.FileUtil;
|
2025-04-16 23:03:41 +08:00
|
|
|
|
2025-05-04 19:55:10 +08:00
|
|
|
namespace Obfuz.Unity
|
2025-04-16 23:03:41 +08:00
|
|
|
{
|
2025-04-17 22:02:48 +08:00
|
|
|
public static class ObfuzMenu
|
2025-04-16 23:03:41 +08:00
|
|
|
{
|
|
|
|
|
2025-05-11 19:28:19 +08:00
|
|
|
[MenuItem("Obfuz/Settings...", priority = 1)]
|
2025-04-16 23:03:41 +08:00
|
|
|
public static void OpenSettings() => SettingsService.OpenProjectSettings("Project/Obfuz");
|
|
|
|
|
2025-05-11 19:28:19 +08:00
|
|
|
[MenuItem("Obfuz/GenerateVM", priority = 62)]
|
|
|
|
public static void GenerateEncryptionVM()
|
|
|
|
{
|
|
|
|
EncryptionVMSettings settings = ObfuzSettings.Instance.encryptionVMSettings;
|
2025-05-17 12:11:36 +08:00
|
|
|
var generator = new VirtualMachineCodeGenerator(settings.codeGenerationSecretKey, settings.encryptionOpCodeCount);
|
2025-05-12 08:13:01 +08:00
|
|
|
generator.Generate(settings.codeOutputPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
[MenuItem("Obfuz/SaveSecretFile", priority = 63)]
|
|
|
|
public static void SaveSecretFile()
|
|
|
|
{
|
2025-05-12 08:46:44 +08:00
|
|
|
SecretSettings settings = ObfuzSettings.Instance.secretSettings;
|
2025-05-12 08:13:01 +08:00
|
|
|
|
2025-05-17 12:11:36 +08:00
|
|
|
var staticSecretBytes = KeyGenerator.GenerateKey(settings.defaultStaticSecretKey, VirtualMachine.SecretKeyLength);
|
2025-05-16 12:33:37 +08:00
|
|
|
SaveKey(staticSecretBytes, settings.DefaultStaticSecretKeyOutputPath);
|
2025-05-16 11:33:03 +08:00
|
|
|
Debug.Log($"Save static secret key to {settings.DefaultStaticSecretKeyOutputPath}");
|
2025-05-17 12:11:36 +08:00
|
|
|
var dynamicSecretBytes = KeyGenerator.GenerateKey(settings.defaultDynamicSecretKey, VirtualMachine.SecretKeyLength);
|
2025-05-16 12:33:37 +08:00
|
|
|
SaveKey(dynamicSecretBytes, settings.DefaultDynamicSecretKeyOutputPath);
|
2025-05-16 11:33:03 +08:00
|
|
|
Debug.Log($"Save dynamic secret key to {settings.DefaultDynamicSecretKeyOutputPath}");
|
2025-05-11 19:28:19 +08:00
|
|
|
}
|
|
|
|
|
2025-05-16 12:33:37 +08:00
|
|
|
private static void SaveKey(byte[] secret, string secretOutputPath)
|
|
|
|
{
|
|
|
|
FileUtil.CreateParentDir(secretOutputPath);
|
|
|
|
File.WriteAllBytes(secretOutputPath, secret);
|
|
|
|
}
|
|
|
|
|
2025-04-16 23:03:41 +08:00
|
|
|
[MenuItem("Obfuz/Documents/Quick Start")]
|
|
|
|
public static void OpenQuickStart() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/beginner/quickstart");
|
|
|
|
|
|
|
|
[MenuItem("Obfuz/Documents/FAQ")]
|
|
|
|
public static void OpenFAQ() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/faq");
|
|
|
|
|
|
|
|
[MenuItem("Obfuz/Documents/Common Errors")]
|
|
|
|
public static void OpenCommonErrors() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/commonerrors");
|
|
|
|
|
|
|
|
[MenuItem("Obfuz/Documents/Bug Report")]
|
|
|
|
public static void OpenBugReport() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/help/issue");
|
|
|
|
|
|
|
|
[MenuItem("Obfuz/Documents/GitHub")]
|
|
|
|
public static void OpenGitHub() => Application.OpenURL("https://github.com/focus-creative-games/obfuz");
|
|
|
|
|
2025-04-17 22:02:48 +08:00
|
|
|
[MenuItem("Obfuz/Documents/About")]
|
|
|
|
public static void OpenAbout() => Application.OpenURL("https://obfuz.doc.code-philosophy.com/docs/intro");
|
2025-04-16 23:03:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|