@li0ard/kuznyechik
Kuznyechik cipher implementation in pure TypeScript
docs
Warning
This library is currently in alpha stage: the lib is not very stable yet, and there may be a lot of bugs feel free to try it out, though, any feedback is appreciated!
# from NPM
npm i @li0ard/kuznyechik
# from JSR
bunx jsr i @li0ard/kuznyechik
- Electronic Codebook (ECB)
- Cipher Block Chaining (CBC)
- Cipher Feedback (CFB)
- Counter (CTR)
- Output Feedback (OFB)
- MAC (CMAC/OMAC/OMAC1)
- Counter with Advance Cryptographic Prolongation of Key Material (CTR-ACPKM)
- MAC with Advance Cryptographic Prolongation of Key Material (OMAC-ACPKM)
- Multilinear Galois Mode (MGM)
- Provides simple and modern API
- Most of the APIs are strictly typed
- Fully complies with GOST R 34.12-2015 (RFC 7801) and GOST R 34.13-2015 (in Russian) standarts
- Supports Bun, Node.js, Deno, Browsers
import { decryptECB, encryptECB } from "@li0ard/kuznyechik";
const key = Buffer.from("8899AABBCCDDEEFF0011223344556677FEDCBA98765432100123456789ABCDEF", "hex")
const plaintext = Buffer.from("1122334455667700ffeeddccbbaa9988", "hex")
const encrypted = encryptECB(key, plaintext)
console.log(encrypted) // Uint8Array [ ... ]
const decrypted = decryptECB(key, encrypted)
console.log(decrypted) // Uint8Array [ ... ]
import { decryptCTR_ACPKM, encryptCTR_ACPKM } from "@li0ard/kuznyechik"
const key = Buffer.from("8899AABBCCDDEEFF0011223344556677FEDCBA98765432100123456789ABCDEF", "hex")
const iv = Buffer.from("1234567890ABCEF0", "hex")
const plaintext = Buffer.from("1122334455667700FFEEDDCCBBAA998800112233445566778899AABBCCEEFF0A112233445566778899AABBCCEEFF0A002233445566778899AABBCCEEFF0A001133445566778899AABBCCEEFF0A001122445566778899AABBCCEEFF0A001122335566778899AABBCCEEFF0A0011223344", "hex")
const encrypted = encryptCTR_ACPKM(key, plaintext, iv)
console.log(encrypted) // Uint8Array [...]
const decrypted = decryptCTR_ACPKM(key, encrypted, iv)
console.log(decrypted) // Uint8Array [...]