CLI tool to encrypt/decrypt files and folders. Easy to use, easy to install.
Also usable as a Deno module for encrypting/decrypting files or folders.
lock
Encryption
lock file.txt
Will prompt for key, encrypt the content and rename the file or directory to
file.txt.lock
Decryption
lock --unlock file.txt.lock
Will prompt for key, decrypt the content, and rename the file or directory back
to file.txt
Help
lock --help
Disclaimer: Use at your own risk, or for fun. This application works, and fully encrypt your files. However the original files are deleted, but not wiped physically from disk after encryption, and could possibly be recovered using forensic tools.
Installation
Pre compiled binaries are not included as the installation consist of two simple one liners, whether you are on Windows, Linux och OSX.
Step 1 - Install Deno runtime
First, make sure Deno is installed. Use one of the one-liners at deno.land/#installation.
Note that deno install require administrator shell to properly install on windows.
Step 2 - Install Lock
deno install --allow-read --allow-write --unstable https://cdn.jsdelivr.net/gh/hexagon/lock@0.9.9/lock.ts
This will automatically pull the latest version from this repository.
Upgrading from a previous version
Passing -f -r
to the installation command will clear cache and upgrade lock to
the latest version.
deno install -f -r --allow-read --allow-write --unstable https://cdn.jsdelivr.net/gh/hexagon/lock@0.9.9/lock.ts
Development
Contribution guide
Development run
deno run --unstable --allow-write --allow-read lock.ts
Pre commit checks
Format check
deno fmt --check
Lint
deno lint
Test & Coverage profile generation
deno test --reload --unstable --allow-write --allow-read --coverage=cov_profile
Read coverage report
deno coverage --exclude=test cov_profile
Using as a module
In addition to being a cli tool, lock is also usable as a module, through mod.ts
TypeScript example
import { lock } from "https://cdn.jsdelivr.net/gh/hexagon/lock@0.9.9/mod.ts";
async function example() {
const fileName = "output.png",
unlock = false, // false = encrypt, true = decrypt
quiet = true, // no console output, setting this to false will output progress, line by line
deleteInputFile = true, // delete input file without confirmation
keepInputFile = false, // keep input file without confirmation
// setting both these to false will trigger a prompt asking how to do
plainKey = "SuperSecretPassword!";
// This will
// * encrypt fileName or the entire folder tree, in case fileName is a directory
// * output fileName + .lock (test.txt.lock) in this case
// * delete fileName (recursively if a directory)
await lock(fileName, unlock, quiet, deleteInputFile, keepInputFile, plainKey);
// This will
// * decrypt fileName + ".lock" (test.txt.lock in this case)
// * output all files that were encrypted previously (recursively if a directory)
// * delete fileName + ".lock"
await lock(
fileName + ".lock",
!unlock,
quiet,
deleteInputFile,
keepInputFile,
plainKey,
);
}
await example();