belt - v0.1.4
    Preparing search index...

    belt - v0.1.4

    @li0ard/belt
    BelT (STB 34.101.31) cipher implementation in pure TypeScript
    docs




    # from NPM
    npm i @li0ard/belt

    # from JSR
    bunx jsr i @li0ard/belt
    • [x] Electronic Codebook (ECB)
    • [x] Cipher Block Chaining (CBC)
    • [x] Counter (CTR)
    • [x] Cipher Feedback (CFB)
    • [x] Message Authentication Code (MAC)
    • [x] Key wrapping (KWP)
    • [x] Ctr-Hash-Encrypt (CHE / AEAD)
    • [x] Datawrap (DWP / AEAD)
    • [x] Compress function
    • [x] Key expand function
    • [x] Key transform function (KRP)
    • [x] Blockwise disk encryption (BDE)
    • [x] Sectorwise disk encryption (SDE)
    • [x] Hash function (HASH)
    • [x] Wide block (WBL)
    • Provides simple and modern API
    • Most of the APIs are strictly typed
    • Fully complies with STB 34.101.31 (in Russian) standard
    • Supports Bun, Node.js, Deno, Browsers
    import { encryptECB, decryptECB } from "@li0ard/belt";

    let key = hexToBytes("E9DEE72C8F0C0FA62DDB49F46F73964706075316ED247A3739CBA38303A98BF6");
    let pt = hexToBytes("b194bac80a08f53b366d008e584a5de48504fa9d1bb6c7ac252e72c202fdce0d5be3d61217b96181fe6786ad716b890b");
    let ct = hexToBytes("69cca1c93557c9e3d66bc3e0fa88fa6e5f23102ef109710775017f73806da9dc46fb2ed2ce771f26dcb5e5d1569f9ab0");

    console.log(encryptECB(key, pt));
    console.log(decryptECB(key, ct));
    import { encryptCBC, decryptCBC } from "@li0ard/belt";

    let key = hexToBytes("E9DEE72C8F0C0FA62DDB49F46F73964706075316ED247A3739CBA38303A98BF6");
    let iv = hexToBytes("BE32971343FC9A48A02A885F194B09A1");
    let pt = hexToBytes("b194bac80a08f53b366d008e584a5de48504fa9d1bb6c7ac252e72c202fdce0d5be3d61217b96181fe6786ad716b890b");
    let ct = hexToBytes("69cca1c93557c9e3d66bc3e0fa88fa6e5f23102ef109710775017f73806da9dc46fb2ed2ce771f26dcb5e5d1569f9ab0");

    console.log(encryptCBC(key, pt, iv));
    console.log(decryptCBC(key, ct, iv));