Sigaba is a command-line tool for encrypting selected values in configuration files. It is designed for sensitive data such as passwords, API keys, and connection strings.
Once encrypted, the file remains human-readable, but matching values are replaced with encrypted values.
So, before encryption you would have a file with the following content:
{
"private_field_secret": "some secret data",
"public_field": "public value"
}and/or
KEY_SECRET=some secret data
KEY=valueand after the encryption:
{
"private_field_secret": "ENC(XAKfHKC...)",
"public_field": "public value"
}and/or
KEY_SECRET=ENC(AJFFKTRS...)
KEY=valueImportant: Sigaba currently supports only JSON and .env files.
Run:
dotnet tool install --global Sigaba
sigaba init
> Enter a password to encrypt the private key: ********
> Enter the password again to confirm: ********Edit sigaba.json to select which files and fields will be encrypted or decrypted.
Move the private key from <user profile folder>\.sigaba\private.key to a secure location.
sigaba encryptPut the private key file (private.key) in:
- the current working directory, or
- in a folder defined in the environment variable
SIGABA_PRIVATE_KEY_DIR, or - in the
.sigabafolder in the user profile, in a subfolder matching theprojectIdin thesigaba.jsonfile. - anywhere, since you can specify its path with the
--private-key-fileoption.
Then run:
sigaba decrypt -p <password>or
sigaba decrypt -p <password> -k <path-to-private-key>sigaba edit <path-to-file>- Encrypts any kind of JSON values — strings, numbers, booleans, arrays, and even nulls — except entire objects (see limitations below).
- Encrypts .env files.
- Preserves comments and formatting after decryption and encryption.
- Allows users to update the secret values and re-encrypt them, but not decrypt them without the private key and password.
- Searches through nested folders, allowing one configuration file to process multiple projects or subfolders.
Install as a dotnet tool:
dotnet tool install --global Sigabaor with tool manifests:
dotnet new tool-manifest # if you don't have a manifest file yet
dotnet tool install SigabaInitialize Sigaba from your project or solution directory:
sigaba initor
sigaba init --non-interactive --password <password>During initialization, you set the password required to decrypt the files.
The tool creates sigaba.json in the current directory and stores the encrypted private key in the user profile:
- sigaba.json:
- placed in the current working directory, i.e. the folder where you run the command.
- contains the tool configuration (see more below).
- required to perform encryption/decryption, so the tool won't work without it.
- sets the topmost folder where the tool will search for files to encrypt/decrypt.
- this file can be kept in the source control, so that all team members will have the same configuration.
- private.key:
- stored in the user profile for safety, such as
%USERPROFILE%\.sigaba\private.keyon Windows or~/.sigaba/private.keyon Linux and macOS. - it is needed to decrypt files.
- the private key content is encrypted with the provided password, so it is useless without it.
- once created, move it to a secure location.
- do not check it into source control!
- it is generally good practice to allow only an automated system to access the private key through a secure mechanism. For example, in Azure DevOps, you can upload the private key as a secure file and use it during a deployment pipeline.
- stored in the user profile for safety, such as
To encrypt your files, use the following command:
sigaba encryptThe tool looks for files and fields according to the configuration file and encrypts matching values.
Values that are already in the ENC(...) format are left unchanged. To change an encrypted value, use sigaba edit, update the value, save the file, and close the editor. Sigaba will encrypt the new value automatically.
The following command will open the file, allowing you to edit it:
sigaba edit <path-to-file>Once you save the changes and close the editor, the tool will encrypt the file automatically.
To decrypt your files, use:
sigaba decrypt -p <password>To decrypt files, Sigaba requires:
- the password you defined during initialization. You pass it to the command line as shown above. This password is used to decrypt the private key file.
- the private key file
private.keythat was created during initialization. The tool will search for it in the following locations, in order:- A directory path defined in the environment variable
SIGABA_PRIVATE_KEY_DIR - The current working directory, i.e. the folder where you run the command.
- The
.sigabafolder in the user profile, in a subfolder matching theprojectIdinsigaba.json.
- A directory path defined in the environment variable
Keep in mind those locations above when you are planning to use the tool in a CI/CD pipeline, so that the private key is available for decryption.
Or you can use:
sigaba decrypt --password <password> --private-key-file <path-to-private-key>With the --private-key-file option, you can specify the path to the private key file, so the tool will not search for it in the default locations.
To configure the tool, open sigaba.json and edit the fields in the configuration section.
Do not modify the fields outside the configuration section.
The section will contain the following fields:
| Name | Type | |
|---|---|---|
| fieldRegex | string | The regex pattern used to select the fields to be encrypted/decrypted. The pattern is matched against the field name, not its value. |
| include | string array | A glob pattern to filter which file will be encrypted/decrypted. |
| exclude | string array | A glob pattern to filter which file will NOT be encrypted/decrypted. |
With the following configuration:
{
"configuration": {
"fieldRegex": "^.*_secret$",
"include": [ "**/*.secrets.json", "**/*.env" ],
"exclude": [ "**node_modules/**", "**/bin/**", "**/obj/**", "**/dist/**" ]
},
"meta": {
"version": 1,
"projectId": "b5f2a6d1b4124bc38012c2a70c575646",
"publicKey": "ATBZMBMGByqGSM49Ag=="
}
}the tool will work according to these rules:
- the tool will process all files that end with
.secrets.json, such asappsettings.secrets.jsonandmyconfig.secrets.json. - the tool will process all files that end with
.env. - the tool will skip any file inside a node_modules, bin, obj or dist folder.
- in each matching file, the tool will look for field names that end with
_secretand encrypt or decrypt their values.
NOTE: Mind that the regex pattern to match field names is case-insensitive.
Currently, the tool cannot handle nested sigaba.json files in the same folder hierarchy. It means that:
- or you have only one configuration in the project root folder,
- or multiple configurations, each one in a different project subfolder.
Although the tool can reach any field in the document hierarchy, it cannot encrypt entire JSON objects. So if you have:
{
"parent_secret": {
"child_secret": "sensitive data"
}
}will become:
{
"parent_secret": {
"child_secret": "ENC(AAAA...)"
}
}That's to avoid confusion on which level of the document would be encrypted first and the hassle to handle nested encrypted values.
- For decryption, you can place the private key anywhere, as long as you specify its path with the
--private-key-fileoption.
- support for .env files
- updated exclude patterns to include /dist/
- Improved cli experience with better messages
- can run commands with
-qor--quietto suppress messages - can run commands with
--verbosity detailedto show more details
- can run commands with