Swift Secrets is a command line tool written in Swift that generates obfuscated keys file to your Swift project using a configuration file (yml).
- ✅ Generate obfuscated keys using hexadecimal numbers.
- ✅ Easily configuration using a yml file
- ✅ Use a custom salt key size with --factor flag
- ✅ Use local keys or environment keys
- ✅ Generate from anywhere including on CI
Given a very simple project spec file like this:
output: Generated/
keys:
api: ${API}
password: myPassword
Take a look at this little article I wrote explaining a little more about this tool: https://link.medium.com/Tlg2WIrV88
The SwiftSecretKeys generates an obfuscated keys file for make it difficult to dump the contents of the decrypted binary and extract the keys. At runtime, the keys are unscrambled for use in your app.
mint install MatheusMBispo/[email protected]
git clone https://github.com/MatheusMBispo/SwiftSecretKeys.git
cd SwiftSecretKeys
make install
You can download the executable from the link: https://github.com/MatheusMBispo/SwiftSecretKeys/releases
To use this tool just type on terminal:
sskeys generate
To use a especific generation factor, just use the flag "--factor"(Int) to set your custom factor:
sskeys generate -f 128
Simply run:
sskeys generate
This will look for a configuration file in the current directory called sskeys.yml
and generate a file with the name defined in the output property in the config.
Options:
- --config: An optional path to a
.yml
configuration file. Defaults tosskeys.yml
- --factor: An optional value to generate a salt key. Defaults to
32
.
The configuration file must be written in YAML.
output: Generated/
keys:
example: exampleValue
environmentExample: ${example}
- output: String - (Optional) Relative path to generate the
SecretKeys.swift
file. - keys: [String: String] - (Optional) The keys that you want obfuscate. The dictionary key will be the variable name and the value will be obsfuscated.
- You can also use environment variables in your configuration file by using
${VALUE}
.
- You can also use environment variables in your configuration file by using
Using the example configuration file above, we can use the keys generated in our project like this:
let example = SecretKeys.example
let x = SecretKeys.environmentExample
To uninstall you can remove the binary from the /usr/local/bin
folder or execute the command below:
git clone https://github.com/MatheusMBispo/SwiftSecretKeys.git
cd SwiftSecretKeys
make uninstall
There are also others obfuscation tools in the Swift and iOS community.