Skip to Content
新しいバージョン 12 を公開しました 🎉
Obfuscator文字列暗号化カスタムアルゴリズム

カスタムアルゴリズム

カスタム文字列暗号化では、文字列を暗号化および復号するメソッドを独自に定義して、文字列を独自の方法で難読化できます。カスタム文字列暗号化を利用するには、ターゲットアセンブリに EncryptString と DecryptString の 2 つのメソッドを定義する必要があります。どちらのメソッドも同じシグネチャを持ち、文字列をパラメーターとして受け取って文字列を返します。返される文字列は、それぞれ暗号化された文字列と復号された文字列です。これらのメソッドを用意することで、コード内の文字列を任意のカスタム暗号化アルゴリズムで暗号化でき、難読化の処理をより柔軟に制御できます。

/// <summary> /// Encrypt a string. /// </summary> /// <param name="text">The string to encrypt.</param> /// <returns>The encrypted string.</returns> [Obfuscation(Feature = "string encryption encrypt method")] internal static string EncryptString(string text) { // Encrypt the text string and return the encrypted string object. return ...; } /// <summary> /// Decrypt an encrypted string. /// </summary> /// <param name="text">The encrypted string.</param> /// <returns>The decrypted string.</returns> [Obfuscation(Feature = "string encryption decrypt method")] internal static string DecryptString(string text) { // Decrypt the text string and return the decrypted string object. return ...; }

EncryptString メソッドと DecryptString メソッドには、適切な Feature 文字列を指定した Obfuscation 属性を付けます。これにより Babel は、文字列を暗号化および復号するコードのエントリポイントを識別できます。

EncryptString メソッドと DecryptString メソッドを定義し、適切な Obfuscation 属性を付けたら、Babel でカスタム文字列暗号化を有効にできます。

カスタム文字列暗号化は、Babel Desktop、コマンドライン、MSBuild タスクのいずれかで有効にできます。

Babel Desktop

Babel Desktop では、アセンブリを選択し、プロパティパネルの「コード暗号化」グループで StringEncryption を custom に設定します。

さらに、暗号化機能をカスタマイズおよび拡張できるように、Babel は外部プラグインの統合をサポートしています。この機能により、アプリケーション固有のニーズとセキュリティ要件に合わせた、より柔軟で堅牢な暗号化の仕組みを実現できます。

コマンドライン

コマンドラインから Babel のカスタム文字列暗号化を有効にするには、次のコマンドを入力します。

babel myapp.exe --strings custom

MSBuild の Babel タスク

Babel タスクを使用している場合は、プロジェクトファイルに次の内容を追加すると、カスタム文字列暗号化を有効にできます。

<PropertyGroup> <StringEncryption>custom</StringEncryption> </PropertyGroup> <Babel StringEncryption="$(StringEncryption)" ... />

また、外部プラグインを使ってカスタム文字列暗号化を実装することもできます(Babel Obfuscator のプラグインを参照してください)。

Last updated on