magma - v0.1.3
    Preparing search index...

    magma - v0.1.3

    @li0ard/magma
    Magma 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/magma

    # from JSR
    bunx jsr i @li0ard/magma
    • [x] Electronic Codebook (ECB)
    • [x] Cipher Block Chaining (CBC)
    • [x] Cipher Feedback (CFB)
    • [x] Counter (CTR)
    • [x] Output Feedback (OFB)
    • [x] MAC (CMAC/OMAC/OMAC1)
    • [x] Counter with Advance Cryptographic Prolongation of Key Material (CTR-ACPKM)
    • [x] MAC with Advance Cryptographic Prolongation of Key Material (OMAC-ACPKM)
    • [x] Multilinear Galois Mode (MGM)
    import { decryptECB, encryptECB } from "@li0ard/magma";

    const key = Buffer.from("ffeeddccbbaa99887766554433221100f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "hex")
    const plaintext = Buffer.from("fedcba9876543210", "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/magma"

    const key = Buffer.from("8899AABBCCDDEEFF0011223344556677FEDCBA98765432100123456789ABCDEF", "hex")
    const iv = Buffer.from("12345678", "hex")
    const plaintext = Buffer.from("1122334455667700FFEEDDCCBBAA998800112233445566778899AABBCCEEFF0A112233445566778899AABBCCEEFF0A002233445566778899", "hex")

    const encrypted = encryptCTR_ACPKM(key, plaintext, iv)
    console.log(encrypted) // Uint8Array [...]

    const decrypted = decryptCTR_ACPKM(key, encrypted, iv)
    console.log(decrypted) // Uint8Array [...]