locka
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

🔐 Locka

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


⚡ Install

npm install -g locka       # CLI + importable API
# or
npx locka                  # use without install

🛠️ CLI Usage

🔐 Encrypt a message

locka encrypt "top secret" --password swordfish

🔓 Decrypt a message

locka decrypt "locka$1$...$..." --password swordfish

🔐 Encrypt a file

locka encrypt-file secret.txt --password swordfish

🔓 Decrypt a file

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

🔑 Generate a password

locka gen password --length 24 --symbols

Options:

  • --symbols: include special characters
  • --no-uppercase: exclude A-Z
  • --no-numbers: exclude 0-9

🎟️ Generate a token

locka gen token --length 64 --base64

Options:

  • --base64: base64 output
  • --raw: return raw Buffer
  • default: hex string

📦 Programmatic API

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);

🌐 Browser Support

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");

✅ Testing

npm test

Runs a full test suite on AES, token parsing, password generation, hashing, and XOR logic with a summary report.


🤖 Requirements

  • Node.js 18+
  • Works in CLI, ESM projects, and the browser (via src/web.js)

🪪 License

This project is licensed under the MIT License. See LICENSE for details.

Package Sidebar

Install

npm i locka

Weekly Downloads

5

Version

1.1.1

License

MIT

Unpacked Size

24.6 kB

Total Files

10

Last publish

Collaborators

  • ghostcar5153