Custom String Encryption lets PreEmptive Protection™ DashO™ use your own encryption algorithm, instead of its default String Encryption, for the strings it finds during processing. Use it for particularly sensitive strings. Your implementation can be as simple or as complex as you want.
Custom String Encryption has two parts:
| Part | When it runs | Where it lives |
| Encryption method | When DashO processes your project | A separate JAR file, outside your project |
| Decryption method | When your app runs | Your project inputs. DashO packages it with your app. |
Prerequisites
- A DashO project.
- A way to package your encryption class into a JAR file separate from your project.
Method Requirements
| Requirement | Encryption method | Decryption method |
| Modifiers | public static | public static |
| Parameters | One string: the plaintext | Two strings, in this order: the key and the ciphertext |
| Returns | An array of two non-null strings, in this order: the key and the ciphertext | One non-null string: the plaintext |
| Location | A separate JAR file, outside your project | A class in your project inputs |
| In the protected output? | No | Yes. Other project settings may rename or obfuscate it. |
The decryption method must correctly decrypt the ciphertext your encryption method creates.
Set Up Custom String Encryption
Step 1: Write the Encryption Method
Write a public static method that meets the encryption requirements. Use the following template:
public static String[] encrypt(String plainText) {
String key = {however you want to determine it};
String cipherText = {however you want to create it};
return new String[] { key, cipherText };//The order is important!
}Package the encryption class in a JAR file, separate from your project.
Note: Return the key first and the ciphertext second.
Step 2: Write the Decryption Method
Write a public static method that meets the decryption requirements. Use the following template:
public static String decrypt(String key, String cipherText) {
String plainText = {however you want to determine it};
return plainText;
}- Add the decryption class to your project inputs.
-
If your decryption class uses other classes in your inputs, exclude those classes from String Encryption.
Step 3: Configure DashO
- On the Custom String Encryption page, select Use Custom Encryption.
- Specify the encryption JAR file, the encryption class and method, and the decryption class and method. For more information, see Configure Custom Encryption.
Step 4: Include the Code to Protect
-
In the Include section of the Custom Encryption page, create rules for the methods, classes, or packages to protect with Custom String Encryption. See Graphical Rules Editor.
Warning: If you don't explicitly include anything, DashO doesn't use Custom String Encryption.
- Make sure the included code isn't excluded from String Encryption. Classes and methods excluded from String Encryption aren't protected with Custom String Encryption.
- Save your project and build it to apply the changes.
Limitations and Troubleshooting
| Issue | Cause and resolution |
| DashO doesn't apply Custom String Encryption. | Nothing is included in the Include section, or the included code is excluded from String Encryption. Add include rules, and check the String Encryption exclude rules. |
| The app makes an infinite recursive call at runtime. | DashO encrypted strings in a class your decryption class uses. Exclude that class from String Encryption. |
| The app is slow after protection. | Your decryption method takes too long. Simplify it, or include less code. |
| Choose… doesn't list your method. | The method doesn't meet the requirements. |