@li0ard/des
v0.1.1
Published
DES cipher implementation in pure TypeScript
Readme
Installation
# from NPM
npm i @li0ard/des
# from JSR
bunx jsr i @li0ard/desSupported algorithms
- [x] Classic DES
- [x] 3DES-EDE
Supported modes
- [x] Electronic Codebook (ECB)
- [x] Cipher Block Chaining (CBC)
- [x] Cipher Feedback (CFB)
- [x] Counter (CTR)
- [x] Output Feedback (OFB)
- [x] Retail MAC (ISO/IEC 9797-1 Algorithm 3)
Features
- Provides simple and modern API
- Most of the APIs are strictly typed
- Fully complies with FIPS 46-3 standard
- Supports Bun, Node.js, Deno, Browsers
Examples
ECB mode
import { decryptECB, encryptECB } from "@li0ard/des";
const key = Buffer.from("1122334455667788", "hex");
const plaintext = Buffer.from("11223344556677881122334455667788", "hex");
const encrypted = encryptECB(key, plaintext);
console.log(encrypted); // Uint8Array [ ... ]
const decrypted = decryptECB(key, encrypted);
console.log(decrypted); // Uint8Array [ ... ]ECB mode (3DES-EDE)
import { decryptECB, encryptECB } from "@li0ard/des";
const key = Buffer.from("1122334455667788...1122334455667788", "hex");
const plaintext = Buffer.from("11223344556677881122334455667788", "hex");
const encrypted = encryptECB(key, plaintext, true);
console.log(encrypted); // Uint8Array [ ... ]
const decrypted = decryptECB(key, encrypted, true);
console.log(decrypted); // Uint8Array [ ... ]