2 CBT Format
riomoo edited this page 2026-02-04 01:59:57 -05:00

CBT File Format

Overview

CBT (Comic Book TAR) is a comic book archive format that uses TAR (Tape Archive) as the container format instead of ZIP. Gopherbook supports both unencrypted and AES-256 encrypted CBT files.

Format Specification

Basic Structure

A CBT file is simply a TAR archive containing:

  • Image files (JPEG, PNG, GIF, AVIF, JXL, WebP, BMP, JP2)
  • ComicInfo.xml (optional metadata)

File Extensions

  • .cbt - Standard CBT file

Supported Image Formats

  • .jpg, .jpeg - JPEG images
  • .png - PNG images
  • .gif - GIF images
  • .avif - AVIF images
  • .jxl - JPEG XL images
  • .webp - WebP images
  • .bmp - Bitmap images
  • .jp2 - JPEG 2000 images

Encryption

Encryption Method

Gopherbook uses AES-256-CFB (Cipher Feedback mode) for encryption:

  1. Key Derivation: SHA-256 hash of the password
  2. IV Generation: Random 16-byte initialization vector
  3. Encryption: AES-256-CFB on the entire TAR archive
  4. Storage: IV prepended to ciphertext

Encrypted File Structure

[16 bytes IV][Encrypted TAR data...]

Compatibility

The encryption format is compatible with:

  • OpenSSL command-line tools
  • Gopherbook's Go implementation
  • The provided bash script (cbt.sh)

ComicInfo.xml

CBT files can include a ComicInfo.xml file for metadata. Gopherbook extracts:

  • Title - Comic title
  • Series - Series name
  • Number - Issue number
  • Writer - Writer name
  • Artist / Inker - Artist name
  • Publisher - Publisher name
  • Genre / Tags - Tags/genres
  • StoryArc - Story arc name
  • Year - Publication year
  • Month - Publication month
  • Summary - Description
  • PageCount - Number of pages

Example ComicInfo.xml

<?xml version="1.0" encoding="utf-8"?>
<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Title>The Amazing Adventure</Title>
    <Series>Super Comics</Series>
    <Number>42</Number>
    <Writer>John Doe</Writer>
    <Artist>Jane Smith</Artist>
    <Publisher>Comic Press</Publisher>
    <Genre>Action, Adventure</Genre>
    <Tags>superhero, action</Tags>
    <StoryArc>The Grand Quest</StoryArc>
    <Year>2024</Year>
    <Month>1</Month>
    <Summary>An epic tale of heroism...</Summary>
    <PageCount>24</PageCount>
</ComicInfo>

CBT vs CBZ

Advantages of CBT

  1. Simpler Format: TAR is simpler than ZIP
  2. Better for Streaming: Sequential structure
  3. Unix-Friendly: Native TAR tools on all Unix systems
  4. Compression Agnostic: Images already compressed

Advantages of CBZ

  1. More Common: Wider software support
  2. Per-File Compression: Can compress text metadata
  3. Random Access: Easier to extract single files

When to Use CBT

  • Unix/Linux environments
  • Streaming applications
  • Encrypted archives (simpler encryption)
  • Archival purposes

When to Use CBZ

  • Windows environments
  • Maximum compatibility
  • Need per-file compression
  • Most comic readers

Creating CBT Files

See the Creating CBT Files page for detailed instructions using:

  • The cbt.sh bash script
  • The cbt.go Go program
  • Manual TAR commands

Technical Details

Encryption Algorithm Details

Algorithm: AES-256-CFB
Key: SHA256(password) = 32 bytes
IV: Random 16 bytes
Block Size: 16 bytes (128 bits)
Mode: CFB (Cipher Feedback)

Decryption Process

  1. Read first 16 bytes as IV
  2. Read remaining bytes as ciphertext
  3. Derive key from password using SHA-256
  4. Decrypt using AES-256-CFB with IV and key
  5. Extract TAR archive from plaintext

Validation

To check if a CBT is encrypted:

# Try reading as TAR
tar -tf file.cbt

# If it fails, likely encrypted
# If it succeeds, unencrypted

File Organization

Gopherbook automatically organizes CBT files:

library/
└── [Artist]/
    └── [StoryArc]/
        └── comic.cbt

Based on extracted metadata from ComicInfo.xml.

Best Practices

  1. Always include ComicInfo.xml for proper metadata
  2. Use consistent naming for images (001.jpg, 002.jpg, etc.)
  3. Encrypt sensitive content using strong passwords
  4. Store passwords securely (Gopherbook does this automatically)
  5. Backup your library regularly

Note: CBT support is a unique feature of Gopherbook. Most comic readers only support CBZ/CBR formats.