Format Overview
FromDOC/7zFormat.txt:
7z archive can contain files compressed with any method. The format supports:
- Solid compression
- Multiple compression methods
- Strong AES-256 encryption
- Large file support (16 EB limit)
- Unicode filenames
- File attributes and timestamps
Archive Structure
A 7z archive consists of:Signature Header
From7z.h (lines 11-14):
Header Types
FromDOC/7zFormat.txt (lines 100-150):
Compression Methods
FromDOC/Methods.txt, method IDs:
Common Methods
| Method | ID | Description |
|---|---|---|
| Copy | 00 | No compression |
| LZMA | 03 01 01 | LZMA algorithm |
| LZMA2 | 21 | LZMA2 (default) |
| PPMd | 03 04 01 | Prediction by partial matching |
| BZip2 | 04 02 02 | Burrows-Wheeler transform |
| Deflate | 04 01 08 | Deflate (ZIP) |
Filters
| Filter | ID | Description |
|---|---|---|
| BCJ | 04 | x86 executable filter |
| BCJ2 | 03 03 01 1B | x86 advanced filter |
| ARM | 07 | ARM executable filter |
| ARM64 | 0A | ARM64 filter |
| Delta | 03 | Delta filter |
Folder Structure
From7z.h (lines 42-51):
- Can contain multiple files (solid compression)
- Defines the compression method chain
- Stores coder properties
Coder Information
From7z.h (lines 24-30):
File Information
File Item
From7z.h (lines 56-66):
File Attributes
Windows attributes:Encryption
7zAES
Method ID:06 F1 07 01
From DOC/Methods.txt (lines 172-173):
- Concatenate: Password + Salt
- Hash with SHA-256, repeated 2^NumCycles times
- Result: 32-byte AES key
Header Encryption
When-mhe=on is used:
- Archive headers are compressed
- Compressed headers are encrypted with AES-256
- Only signature header remains unencrypted
- Password required to list files
Archive Database
From7z.h (lines 79-96):
Format Limits
| Property | Limit | Note |
|---|---|---|
| File size | 16 EB | 2^64 bytes |
| Archive size | 16 EB | 2^64 bytes |
| Files per archive | 2^32 | 4 billion |
| Filename length | 2^16 chars | 64K Unicode chars |
| Solid block size | Unlimited | Memory constrained |
| Dictionary size | 1.5 GB | LZMA2 limit |
Reading 7z Archives
Opening Archive
FromDOC/7zC.txt (lines 93-107):
Extracting Files
Creating 7z Archives
Archive Handler
FromCPP/7zip/Archive/7z/7zHandler.h:
Update Operations
Format Advantages
High Compression
LZMA2 provides excellent compression ratios
Solid Compression
Compress similar files together for better ratios
Strong Encryption
AES-256 encryption with SHA-256 key derivation
Large File Support
Support for files and archives up to 16 EB
Unicode Names
Full Unicode support for filenames
Extensible
Support for custom compression methods
Format Comparison
| Feature | 7z | ZIP | TAR.GZ | RAR |
|---|---|---|---|---|
| Compression | Excellent | Good | Good | Excellent |
| Speed | Medium | Fast | Fast | Medium |
| Solid | Yes | No | No | Yes |
| Encryption | AES-256 | AES-256 | None | AES-256 |
| Header encryption | Yes | No | No | Yes |
| Multi-threading | Yes | Partial | No | Yes |
| Open source | Yes | Yes | Yes | No |
Implementation Files
Key source files:- Format handler:
CPP/7zip/Archive/7z/7zHandler.cpp - Archive reader:
C/7zArcIn.c - Decoder:
C/7zDec.c - Header structures:
C/7z.h - Format constants:
CPP/7zip/Archive/7z/7zHeader.h
Format Documentation
Complete format specification:DOC/7zFormat.txt- Full format specificationDOC/Methods.txt- Compression method IDsDOC/7zC.txt- ANSI-C decoder documentation