Skip to content

A Swift command line tool for generating Secrets for your Swift project

Notifications You must be signed in to change notification settings

rebeccachin/SwiftSecretKeys

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Swift

Swift Secret Keys

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

Why use it

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.

Installing

Mint

mint install MatheusMBispo/[email protected]

Make

git clone https://github.com/MatheusMBispo/SwiftSecretKeys.git
cd SwiftSecretKeys
make install

Binary

You can download the executable from the link: https://github.com/MatheusMBispo/SwiftSecretKeys/releases

Getting Started

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

Usage

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 to sskeys.yml
  • --factor: An optional value to generate a salt key. Defaults to 32.

Configuration

The configuration file must be written in YAML.

Properties

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} .

On Code:

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

Uninstalling

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

Other libraries

There are also others obfuscation tools in the Swift and iOS community.

About

A Swift command line tool for generating Secrets for your Swift project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 96.4%
  • Makefile 3.6%