Java reflection-based embedded data obfuscation method
By generating dynamic obfuscation keys using Java reflection technology, dynamically collecting and embedding sensitive data, and combining multi-dimensional obfuscation operations and self-verification protection, the problem of Java data being easily cracked and having high resource consumption in embedded systems is solved, achieving high security and low resource consumption data protection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING XUANYI TECHNOLOGY CO LTD
- Filing Date
- 2026-05-15
- Publication Date
- 2026-07-03
AI Technical Summary
Existing Java data obfuscation techniques have problems in embedded systems, such as being easily cracked, consuming a lot of resources, and being unable to resist dynamic debugging attacks, leading to the leakage of sensitive data.
Using Java reflection technology, a dynamic obfuscation key is generated by obtaining hardware identifiers, class paths, and timestamps. Sensitive data is dynamically collected, and combined with segmented XOR, bitwise obfuscation, and custom Base64 encryption, it is embedded in the class constant pool for storage. At runtime, it dynamically deobfuscates and performs self-verification protection.
It achieves lightweight and dynamic data protection, improves the security of embedded Java environments, avoids external dependencies and resource consumption, and is suitable for resource-constrained embedded systems.
Smart Images

Figure CN122333428A_ABST
Abstract
Description
1. Technical Field
[0001] This invention relates to the field of sensitive data detection and sensitive data processing technology, specifically to an embedded data obfuscation method based on Java reflection, applicable to scenarios such as Java embedded development boards, Android embedded devices, IoT Java terminals, and industrial control Java programs, and can achieve high-strength protection of keys, configuration files, and user data. 2. Background Technology
[0002] Due to its cross-platform compatibility, object-oriented nature, and ease of development, the Java language is widely used in embedded systems, mobile terminals, and enterprise application development. However, Java bytecode files are extremely easy to decompile using decompilation tools, which can directly expose sensitive data stored in the program, leading to security issues such as data leaks, program tampering, and piracy.
[0003] Existing Java data obfuscation techniques suffer from the following drawbacks: static, hard-coded obfuscation rules are fixed and easily cracked; they rely on external obfuscation libraries or configuration files, making them unsuitable for resource-constrained embedded systems; the obfuscation and deobfuscation logic is rigid, making them vulnerable to dynamic debugging attacks; and they incur high computational overhead, resulting in poor embedded system adaptability. Therefore, there is an urgent need for a lightweight, dynamic, and externally independent Java embedded data obfuscation method. 3. Summary of the Invention
[0004] This invention provides an embedded data obfuscation method based on Java reflection, which solves the problems of sensitive data being easily decompiled and leaked, obfuscation logic being fixed, and high resource consumption in Java embedded applications, and achieves lightweight, dynamic, and highly secure embedded data protection.
[0005] This invention includes the following steps: S1. Initialize the obfuscation context: Obtain parameters related to the currently running class through Java reflection, cache hardware identifier, classpath, and timestamp as obfuscation factors, and generate a dynamic obfuscation key; S2. Dynamic collection of sensitive data: Based on the reflection scan of private fields marked as sensitive data, the raw data is automatically collected without modifying the business code; S3. Multidimensional dynamic obfuscation operation: Combines obfuscation factors to perform segmented XOR, shift obfuscation, and custom mutation Base64 encryption; S4. Embedded data storage: Obfuscated data is written to a private static field via reflection, embedded in the class constant pool, with no external file dependency; S5. Runtime dynamic deobfuscation: Decryption and restoration are completed in memory at runtime, and the data is cleared immediately after use without being written to disk; S6. Self-verification protection: Verifies the integrity of obfuscated logic classes through reflection, and automatically destroys sensitive data if an attack is detected.
[0006] This invention requires no external dependencies, is computationally lightweight, and has low invasiveness, which can significantly improve the security of sensitive data in embedded Java environments. 4. Description of the attached drawings
[0007] Figure 1 is a flowchart of the embedded data obfuscation method based on Java reflection of the present invention. 5. Detailed Implementation
[0008] The specific implementation steps of this invention are as follows: S1. Initialize the obfuscation context: Obtain the device MAC address, class hash value, and timestamp, and combine them to generate a unique obfuscation key. The key is only used in memory and is not stored on the disk. S2. Dynamic Acquisition of Sensitive Data: By scanning sensitive private fields marked in the target class through reflection, the data to be obfuscated is collected by bypassing access permissions. S3. Multidimensional dynamic obfuscation operation: After segmenting the original data, XOR it with the key, perform shift obfuscation, and then generate the final obfuscated string through custom mutation Base64; S4. Embedded data storage: Reflection bypasses permission checks, encapsulates obfuscated data into a private static final byte array, and embeds it into the class constant pool; S5. Runtime dynamic deobfuscation: Decryption is performed at runtime via reflection, only in memory, and the original data is cleared immediately after use; S6. Self-verification protection: Obtain the method signature and hash value of the obfuscated logic class through reflection, compare it with the pre-stored value, and if they do not match, it is determined to be an attack and sensitive data is destroyed.
[0009] This invention is implemented entirely using Java reflection, with no business code intrusion and no external dependencies. It is adapted to resource-constrained embedded Java environments and possesses high security and strong practicality.
Claims
1. An embedded data obfuscation method based on Java reflection, characterized in that, Includes the following steps: S1. Initialize the obfuscation context: Obtain the class loader, field modifiers, and runtime environment parameters of the currently running class through Java reflection, build a lightweight obfuscation context, and cache the embedded system hardware identifier, classpath, and timestamp as obfuscation factors; S2. Dynamic Acquisition of Sensitive Data: Based on reflection scanning of private fields marked as sensitive data in the target class, the original data to be obfuscated is automatically collected without modifying the business code logic; S3. Multi-dimensional Dynamic Obfuscation Operation: Combining obfuscation factors, the private methods of the obfuscation utility class are called through reflection to perform a combination of obfuscation operations on the original data, including character substitution, bitwise operations, segmented XOR, and Base64 mutation encryption; S4. Embedded Data Storage: The obfuscated data is dynamically written into a private static field of the target class as a byte array via reflection, completing embedded local storage without external file dependencies; S5. Runtime Dynamic Deobfuscation: During program execution, the private deobfuscation method is called via reflection, and the stored obfuscated data is decrypted in reverse using runtime obfuscation factors to restore the original sensitive data for injection into business logic; S6. Self-Verification Protection: The integrity of the obfuscated logic class is verified via reflection. If tampering or debugging attacks are detected, sensitive data is automatically destroyed, and data restoration is terminated.
2. The method according to claim 1, characterized in that, Step S1 includes: S11. Obtain the embedded device's MAC address, hash value, and timestamp; S12. Combine the three to generate a unique obfuscation key, which is not stored on the ground.
3. The method according to claim 1, characterized in that, Step S3 includes: S31. Segmenting the original string by length, and performing an XOR operation on each segment with the obfuscation key; S32. Using reflection to call the bitwise operation method of the java.lang.Byte class to perform bitwise obfuscation on the XORed data; S33. Replacing the standard encoding table with a custom mutated Base64 encoding to generate the final obfuscated string.
4. The method according to claim 1, characterized in that, Step S4 includes: S41. Using reflection to bypass field access permission checks; S42. Encapsulating the obfuscated data into a private static final byte array and embedding it in the class's constant pool.
5. The method according to claim 1, characterized in that, Step S5 includes: S51. The deobfuscation process is executed only in runtime memory; S52. The restored original data is cleared from memory immediately after use and is not written to disk.
6. The method according to claim 1, characterized in that, Step S6 includes: S61. Self-verification obtains the method signature and class hash value of the obfuscated logic class through reflection; S62. Compare with the pre-stored verification value, and if they are inconsistent, it is determined to be an attack.