Locka is a sleek encryption toolkit and CLI for managing secrets, encrypting files, and generating secure passwords and tokens — with zero dependencies and maximum vibes.
Where the hell have you been loca 🐺.
npm install -g locka # CLI + importable API
# or
npx locka # use without install
locka encrypt "top secret" --password swordfish
locka decrypt "locka$1$...$..." --password swordfish
locka encrypt-file secret.txt --password swordfish
locka decrypt-file secret.txt.lck --password swordfish
Add --output
to rename the output file, and --keep
to preserve the original:
locka encrypt-file note.txt --password mango --output vault.lck --keep
locka gen password --length 24 --symbols
Options:
-
--symbols
: include special characters -
--no-uppercase
: exclude A-Z -
--no-numbers
: exclude 0-9
locka gen token --length 64 --base64
Options:
-
--base64
: base64 output -
--raw
: return raw Buffer - default: hex string
import locka, {
generatePassword,
generateToken,
parse
} from "locka";
// Encrypt and decrypt
const token = locka("top secret").aes("key").toString();
const plain = locka(token).decrypt().aes("key");
// Encode to base64 or hex
const hex = locka("data").hex().toString();
const b64 = locka("data").base64().toString();
// XOR reversible encoding
const encoded = locka("hidden").xor("key").raw();
const decoded = locka(encoded).xor("key").toString();
// Hash
const hash = locka("msg").hash("sha256").toString();
// Passwords & Tokens
const pwd = generatePassword(32, { symbols: true });
const token64 = generateToken(64, "base64");
// Parse tokens
const meta = parse(token);
Locka provides a secure AES-GCM encryptWeb()
and decryptWeb()
API for client-side encryption:
import { encryptWeb, decryptWeb } from "locka/web";
const token = await encryptWeb("text", "password");
const plain = await decryptWeb(token, "password");
npm test
Runs a full test suite on AES, token parsing, password generation, hashing, and XOR logic with a summary report.
- Node.js 18+
- Works in CLI, ESM projects, and the browser (via
src/web.js
)
This project is licensed under the MIT License. See LICENSE for details.