Command-line tool
obfuscate
Keep API keys out of your Swift source.
obfuscate generates a Secrets.swift file in which each secret is encrypted with its own random key, so you can commit it without your API keys appearing in source control.
- macOS
- CLI
Requires macOS 26.
Secrets out of source control
Nothing in plain text
The generated file never contains a secret in plain text, not even in a comment.
A key for every secret
Each secret is encrypted with ChaCha20-Poly1305 (via CryptoKit) using its own random key, and every run produces different output.
Simple to use
Read a secret with one line: let apiKey = try Secrets.openAI
Checks its own work
With --check, obfuscate decodes every secret before writing anything, so a bad file never reaches your project.
How it works
Give obfuscate your secrets and a file name:
$ obfuscate --key openAI=sk-example-1234 -f SecretsThat writes Secrets.swift, containing a Secrets enum, which you can safely commit. Your app reads each secret with let apiKey = try Secrets.openAI. The technique is based on NSHipster’s article on secrets.
Install
Until the signed download is ready, build obfuscate from source with Xcode:
$ git clone https://github.com/pdarcey/obfuscate.git
$ open obfuscate/obfuscate.xcodeprojThen choose Product › Build (⌘B). Each build installs obfuscate to /usr/local/bin and its man page alongside, so obfuscate and man obfuscate work straight away.
Options
- <secret> …: secrets to obfuscate. They become Secrets.apiKey1, Secrets.apiKey2 and so on.
- -k, --key <name=secret>: a secret plus the property name that returns it. Repeat for more secrets.
- -f, --file-name <file>: write to this file instead of standard output (.swift is added if needed).
- -c, --check: check that every secret decodes correctly before writing any output.
Important
This is obfuscation, not high-security encryption: the key for each secret is in the same file. Anyone determined can recover the secrets. obfuscate just means they have to do some work, instead of finding your keys in plain sight.
Requirements and licence
obfuscate runs on macOS 26 or later. It’s free and open source under the MIT licence.
Details
- Platforms
- macOS and CLI
- Requires
- macOS 26
- Category
- Developer Tools
- Price
- Free
- Languages
- English
- Developer
- Xerodonia Pty Ltd