© 2026 José Carrillo
Zefer as a Node.js library
The same encryption engine, importable from your own Node.js code: services, AWS Lambda, or build scripts. ESM and CommonJS.
What is the library channel?
Beyond the CLI and the MCP server, zefer-cli exposes a zero-side-effect programmatic entry point. You import the same functions the web app and CLI use and call them directly from your code. Files produced this way are 100% compatible with the web app and the CLI.
Requires Node.js ≥ 20 · v1.3.0+
Installation
Add the package to your project. The "." export resolves to the library (not the CLI bundle).
npm install zefer-cliImport
Available as ESM and CommonJS, with TypeScript types included.
// ESM / TypeScript
import { encodeZefer, decodeZefer, generateWithOptions, analyzePassword } from "zefer-cli";
// CommonJS
const { encodeZefer, analyzePassword } = require("zefer-cli");Exposed API
The main core functions, identical to those in the web app and CLI.
encodeZefer(options) → Promise<Buffer>
Encrypts text or files into the ZEFB3/ZEFR3 binary format. Returns the encrypted bytes.
decodeZefer(input, passphrase, options) → Promise<{ ok, payload }>
Decrypts a .zefer file. Returns { ok, payload } with the content or file data.
generateWithOptions(mode, length, options) → string
Generates a scored key in 7 modes (unicode, secure, alpha, hex, base58, pin, uuid) with advanced options.
analyzePassword(password) → report
Full report for a password: score, entropy, keyspace, compliance (NIST/OWASP/AES-128/post-quantum) and crack times.
Examples
Encrypt text to .zefer
import { encodeZefer } from "zefer-cli";
import { writeFile } from "node:fs/promises";
const buf = await encodeZefer({
content: "api_key=abc123",
passphrase: "a-strong-passphrase",
fileName: null,
expiresAt: 0,
compression: "gzip",
iterations: 600000,
});
await writeFile("secret.zefer", buf);Decrypt a file
import { decodeZefer } from "zefer-cli";
import { readFile } from "node:fs/promises";
const bytes = await readFile("secret.zefer");
const res = await decodeZefer(bytes.toString("utf-8"), "a-strong-passphrase", {
rawBytes: bytes,
});
if (res.ok) console.log(res.payload.content);Generate and analyze keys
import { generateWithOptions, analyzePassword } from "zefer-cli";
const key = generateWithOptions("base58", 24, { groupSize: 6 });
const report = analyzePassword(key);
console.log(key, report.score, report.entropy);Important notes
- No auto-benchmarking: always pass an explicit iterations value (e.g. 600000).
- Operates in memory: needs RAM ≈ input + output size (on Lambda, ≥512 MB for ~100 MB payloads).
- Files produced are 100% compatible with the web app and the CLI (same format, same parameters).
Files produced are 100% compatible with the web app and the CLI (same format, same parameters).