Awesome
ObfuscateMacro
Swift macros for string obfuscation to protect sensitive data from binary analysis.
<!-- # Badges -->Overview
ObfuscateMacro transforms your strings at compile-time into obfuscated data, with runtime decoding when accessed. Each macro execution uses a different random seed, ensuring that only obfuscated data exists in your binary.
Installation
In Xcode, add ObfuscateMacro as a Swift Package dependency to your project:
- File → Add Package Dependencies
- Enter:
https://github.com/p-x9/ObfuscateMacro.git
- Select version:
0.10.0
or higher
Usage
Import and use the macro:
import ObfuscateMacro
let text = #ObfuscatedString("hello")
Obfuscation Methods
Available methods:
- bit shift: Applies bit shifting operations
- bit XOR: Uses XOR operations
- base64: Base64 encoding with additional obfuscation
- AES: AES encryption
- random: Randomly selects from above methods
Specify Method
let string = #ObfuscatedString("Hello", method: .bitXOR)
Random Selection
// Use any method
let string = #ObfuscatedString("Hello", method: .randomAll)
// Choose from specific methods
let string = #ObfuscatedString("Hello", method: .random([.bitXOR, .AES]))
Enhanced Security
Apply multiple layers of obfuscation:
#ObfuscatedString(
"hello",
repetitions: 5
)
Best Practices
Use this macro for sensitive data like API keys, tokens, and internal URLs. While obfuscation adds protection, remember it's just one part of a complete security strategy.
License
ObfuscateMacro is released under the MIT License. See LICENSE