A simple command-line tool to encrypt and decrypt your .env files using a password. This tool ensures that you can safely push sensitive .env files to a public GitHub repository without exposing sensitive keys.
You can install dotlock globally or use it locally in your project.
To install globally, run:
npm install -g dotlockYou can use dotlock via the command line with the following commands:
This command monitors your .env file for changes and automatically encrypts it when saved:
dotlock watch --password your_password
# or shorthand
dotlock watch -p your_passwordEncrypt your .env file with a password:
dotlock encrypt --password your_password
# or shorthand
dotlock encrypt -p your_passwordDecrypt a previously encrypted .env.enc file with the same password:
dotlock decrypt --password your_password
# or shorthand (note the double dash)
dotlock decrypt -p your_passwordNote: The decryption process will complete even if the password is incorrect, but the file contents will be corrupted and unreadable.
You can also use dotlock locally without installing by running via npx:
npx dotlock encrypt --password your_password