RAILGUN Reloaded
    Preparing search index...

    AES-256 encryption helpers in GCM (authenticated) and CTR (streaming) modes.

    All inputs and outputs are Uint8Array. Keys must be 32 bytes; IVs are generated internally on encrypt and read from the ciphertext bundle on decrypt. GCM and CTR are counter-mode stream ciphers, so the per-block data layout is preserved by encrypting the concatenated blocks in one shot and re-splitting the result at the original block boundaries.

    Index
    • Encrypt blocks of data with AES-256-GCM.

      Parameters

      • plaintext: Uint8Array<ArrayBufferLike>[]

        Blocks of plaintext to encrypt.

      • key: Uint8Array

        32-byte symmetric key.

      Returns Ciphertext

      Ciphertext bundle: iv, auth tag, and per-block encrypted data.

      CryptographyError(InvalidKeyLength) when key is not 32 bytes.

    • Decrypt a ciphertext bundle produced by encryptGCM.

      Parameters

      • ciphertext: Ciphertext

        Bundle of iv, tag, and per-block data.

      • key: Uint8Array

        32-byte symmetric key.

      Returns Uint8Array<ArrayBufferLike>[]

      Per-block decrypted plaintext.

      CryptographyError(InvalidKeyLength | InvalidIvLength | InvalidTagLength) on length validation failures.

      CryptographyError(DecryptionFailed) on auth tag failure or any underlying decipher error.

    • Encrypt blocks of data with AES-256-CTR.

      Parameters

      • plaintext: Uint8Array<ArrayBufferLike>[]

        Blocks of plaintext to encrypt.

      • key: Uint8Array

        32-byte symmetric key.

      Returns CiphertextCTR

      Ciphertext bundle: iv and per-block encrypted data (no auth tag).

      CryptographyError(InvalidKeyLength) when key is not 32 bytes.

    • Decrypt a ciphertext bundle produced by encryptCTR.

      Parameters

      • ciphertext: CiphertextCTR

        Bundle of iv and per-block data.

      • key: Uint8Array

        32-byte symmetric key.

      Returns Uint8Array<ArrayBufferLike>[]

      Per-block decrypted plaintext.

      CryptographyError(InvalidKeyLength | InvalidIvLength) on length validation failures.