# 7z

**7z**是一种文件归档格式，使用`.7z`文件扩展名，由伊戈尔·帕夫洛夫（Igor Pavlov）于1999年为其开源7-Zip归档工具创建，并作为该程序的一部分在GNU LGPL许可下分发。<sup>[1](https://www.7-zip.org/7z.html)</sup><sup> • </sup><sup>[2](https://www.reformatly.com/fileformats/7z.html)</sup>该格式以高压缩比为目标，支持AES-256加密和固实压缩，并拥有公开的格式规范，众多独立工具均可实现，这一点与专有的RAR格式不同——后者的创建仅限于RARLAB自家的软件。<sup>[1](https://www.7-zip.org/7z.html)</sup><sup> • </sup><sup>[3](https://www.rarexplorer.com/guides/7z-vs-rar-vs-zip/)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 由伊戈尔·帕夫洛夫于1999年为7-Zip归档工具创建；7z代码在GNU LGPL下分发<sup>[2](https://www.reformatly.com/fileformats/7z.html)</sup><sup> • </sup><sup>[1](https://www.7-zip.org/7z.html)</sup> |
| 压缩方法 | LZMA（默认）、LZMA2、PPMD、BZip2和Copy（不压缩），外加可执行文件过滤器和Delta过滤器<sup>[1](https://www.7-zip.org/7z.html)</sup> |
| 加密 | AES-256，密钥通过基于SHA-256的函数经多次迭代从密码派生<sup>[1](https://www.7-zip.org/7z.html)</sup> |
| 大小限制 | 支持最大16000000000 GB的文件；Unicode文件名<sup>[1](https://www.7-zip.org/7z.html)</sup> |
| 完整性 | CRC-32校验和存储在签名头中，并为每个打包流单独存储<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup> |
| 实测压缩 | 在一个取自主文件夹的55 MB混合语料库上，7-Zip在最高设置下约4秒内生成原始大小60%的归档文件，比ZIP约小27%<sup>[5](https://github.com/ezyZip/best-archive-format-comparison)</sup> |
| 平台支持 | Windows 11版本23H2的文件资源管理器通过libarchive库解压`.7z`；Windows 10不支持，且无法处理加密归档<sup>[6](https://www.windowscentral.com/software-apps/windows-11/how-to-get-started-with-the-files-app-on-windows-11-to-replace-file-explorer)</sup><sup> • </sup><sup>[7](https://www.universalzip.com/articles/zip-vs-7z-vs-rar/)</sup> |

## 设计目标与特性

7-Zip项目维护的格式页面列出该格式的主要特性为：开放架构、高压缩比、强AES-256加密、可使用任意压缩/转换或加密方法、支持最大16000000000 GB的文件、Unicode文件名、固实压缩以及归档头压缩。<sup>[1](https://www.7-zip.org/7z.html)</sup>开放架构意味着可以在不改变容器的情况下向格式中添加新的压缩方法，源文档中的方法注册表为编解码器分配数字ID，以便解码器识别其所读取的内容。<sup>[1](https://www.7-zip.org/7z.html)</sup><sup> • </sup><sup>[8](https://github.com/ip7z/7zip/blob/main/DOC/Methods.txt)</sup>

**固实压缩。** 在固实模式下，多个同类型文件在单一流内压缩，因此跨文件的冗余被消除，而非逐文件压缩。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup>当归档中包含大量相似文件时，这能提高压缩比，但会使提取单个文件变慢，因为必须从流的起始处开始处理。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup>该格式还会压缩自身的归档头，从而减少大量小条目带来的开销。<sup>[1](https://www.7-zip.org/7z.html)</sup>

## 压缩方法与过滤器

格式集成了五种方法：LZMA，被描述为LZ77算法的改进优化版本；LZMA2，LZMA的改进版；PPMD，对德米特里·什卡林（Dmitry Shkarin）的PPMdH略作修改的版本；BZip2，标准BWT算法；以及Copy，即不压缩直接存储数据。<sup>[1](https://www.7-zip.org/7z.html)</sup>LZMA是默认的通用压缩方法。<sup>[1](https://www.7-zip.org/7z.html)</sup>

该格式还支持在主压缩器运行前对数据进行转换的过滤器，以提高特定文件类型的压缩比：用于x86可执行文件的BCJ和BCJ2，用于ARM64、ARM-Thumb、ARM32、PowerPC、SPARC和[IA-64](https://www.edgepedia.org/zh/ia-64)可执行文件的转换器，用于WAV文件的Delta转换器，以及改变字节序的Swap2/Swap4转换器。<sup>[1](https://www.7-zip.org/7z.html)</sup>

项目文档记载了LZMA在4 GHz CPU上的运行特征：双线程版本压缩速度约2至8 MB/s，单线程解压约30至100 MB/s，字典大小可变，最大4 GB，解压内存需求较小且取决于字典大小，解压器代码约5 KB。<sup>[1](https://www.7-zip.org/7z.html)</sup>

## 加密

7z使用AES-256加密，采用256位密码密钥，该密钥通过基于SHA-256哈希算法的函数从用户文本密码派生；派生过程应用大量迭代以增加穷举密码搜索的成本。<sup>[1](https://www.7-zip.org/7z.html)</sup>虽然`.7z`归档不必加密，但一项关于7-Zip密码学的研究指出，加密的`.7z`归档使用CBC模式的AES-256，而同一程序创建的加密`.zip`归档可使用较旧的ZipCrypto或CTR模式的AES-256。<sup>[9](https://dspace.cvut.cz/bitstream/handle/10467/83024/F8-BP-2019-Husek-Josef-thesis.pdf)</sup><sup> • </sup><sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup>方法注册表将7z的加密算法标识为7zAES，即AES-256与SHA-256的组合。<sup>[8](https://github.com/ip7z/7zip/blob/main/DOC/Methods.txt)</sup>归档头加密可隐藏文件名及内容，属于可选设置而非默认行为。<sup>[9](https://dspace.cvut.cz/bitstream/handle/10467/83024/F8-BP-2019-Husek-Josef-thesis.pdf)</sup>

## 文件结构

7z归档由签名头、随后的打包流和一个头组成，其中头本身可以作为打包头以压缩形式存储。<sup>[10](https://github.com/ip7z/7zip/blob/main/DOC/7zFormat.txt)</sup>该格式使用小端序编码，许多头字段是可选的。<sup>[10](https://github.com/ip7z/7zip/blob/main/DOC/7zFormat.txt)</sup>头描述应用于每个流文件夹的编码器、其参数以及解包大小和CRC值。<sup>[10](https://github.com/ip7z/7zip/blob/main/DOC/7zFormat.txt)</sup>为进行错误检测，签名头携带下一个头的CRC-32，每个打包流有自己的CRC-32，可在提取时校验。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup>美国国会图书馆的格式描述指出，除了解包归档和提取条目所需的信息外，该格式不提供额外的元数据支持。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)</sup>

## 实现与兼容性

由于规范是公开的，该格式在7-Zip本身之外还有独立实现。libarchive库可读写7-Zip归档，包括使用zstandard压缩的归档，py7zr则基于格式规范提供了Python实现。<sup>[11](https://github.com/libarchive/libarchive)</sup><sup> • </sup><sup>[12](https://py7zr.readthedocs.io/en/stable/archive_format.html)</sup>7-Zip的Unix/Linux移植版p7zip也存在，且该格式几乎被所有文件归档工具支持，无论付费还是免费。<sup>[13](https://www.techradar.com/best/free-winzip-alternative)</sup>

在Windows上，原生支持随[Windows 11](https://www.edgepedia.org/zh/windows-11)版本23H2到来，[文件资源管理器](https://www.edgepedia.org/zh/file-explorer)通过集成libarchive开源项目获得了查看和解压`.zip`、`.rar`和`.7z`归档的能力。<sup>[6](https://www.windowscentral.com/software-apps/windows-11/how-to-get-started-with-the-files-app-on-windows-11-to-replace-file-explorer)</sup>该支持不扩展到[Windows 10](https://www.edgepedia.org/zh/windows-10)，且文件资源管理器无法打开加密的此类归档。<sup>[7](https://www.universalzip.com/articles/zip-vs-7z-vs-rar/)</sup>macOS内置的归档实用工具可打开ZIP但不支持7z，因此那里的`.7z`文件仍需第三方应用。<sup>[14](https://www.docuboxer.com/en/blog/rar-vs-zip-vs-7z)</sup>

## 压缩性能

基准测试将7z列为体积方面最强的主流格式之一，代价是压缩速度较慢。在ezyZip比较项目中，对由文本、办公文档、图像和视频组成的真实55 MB混合语料库在各工具的默认和最高设置下进行压缩，7-Zip的`.7z`在最高设置下约4秒内生成原始大小60%的归档，比ZIP约小27%；专用最高压缩器zpaq达到56%，但需要约150秒。<sup>[5](https://github.com/ezyZip/best-archive-format-comparison)</sup>同一基准发现，办公文档在ZIP下几乎不压缩，为原始大小的99%，因为`.docx`和`.xlsx`文件内部已经是ZIP容器，而7-Zip将其重新压缩至60%；照片和视频对所有格式而言都几乎不可压缩，约为98%至100%。<sup>[5](https://github.com/ezyZip/best-archive-format-comparison)</sup>

一项关于归档格式的学术比较同样报告称，由开源7-Zip软件支持的7Z格式通过LZMA算法实现强压缩，非常适合归档大文件，同时指出与RAR等格式相比，7Z提供的恢复功能有限——RAR包含数据恢复记录以抵御损坏。<sup>[15](https://dspace.library.khai.edu/xmlui/bitstream/handle/123456789/8384/SCIFIC-2024.pdf?isAllowed=y&sequence=1)</sup>

## 安全历史

7-Zip应用程序（而非格式本身）的若干漏洞需要手动更新，因为该程序没有自动更新机制。2025年，两个被追踪为CVE-2025-11001和CVE-2025-11002的高危漏洞（CVSS基础评分均为7.0）源于7-Zip解析ZIP文件内符号链接的方式，使得精心构造的归档能够逃逸其预期的提取目录，并在串联利用时以用户权限实现代码执行；开发者伊戈尔·帕夫洛夫于7月5日发布25.00版进行修补，稳定版25.01于8月跟进。<sup>[16](https://www.tomshardware.com/tech-industry/cyber-security/7-zip-flaws-open-door-to-remote-code-execution)</sup>同年早些时候，CVE-2025-0411允许攻击者通过嵌套恶意ZIP绕过Windows网络标记保护，已在24.09版中修复。<sup>[16](https://www.tomshardware.com/tech-industry/cyber-security/7-zip-flaws-open-door-to-remote-code-execution)</sup>2026年，处理XZ分块数据时的一个缺陷允许在用户打开恶意文件时发生基于堆的缓冲区溢出和代码执行，已在26.02版中修复，用户必须手动安装。<sup>[17](https://www.pcgamer.com/software/security/its-probably-time-to-update-7-zip-as-the-app-has-just-been-patched-to-fix-a-pretty-big-vulnerability/)</sup>

## References

1. [7z Format, 7-Zip official documentation](https://www.7-zip.org/7z.html)
2. [7Z: 7-Zip Archive, Reformatly file format library](https://www.reformatly.com/fileformats/7z.html)
3. [7z vs RAR vs ZIP: Which Archive Format to Use?, RareExplorer](https://www.rarexplorer.com/guides/7z-vs-rar-vs-zip/)
4. [7z File Format, Library of Congress Sustainability of Digital Formats](https://www.loc.gov/preservation/digital/formats/fdd/fdd000539.shtml)
5. [The Ultimate Archive Format Comparison, ezyZip benchmark repository](https://github.com/ezyZip/best-archive-format-comparison)
6. [How to get started with the Files App on Windows 11, Windows Central](https://www.windowscentral.com/software-apps/windows-11/how-to-get-started-with-the-files-app-on-windows-11-to-replace-file-explorer)
7. [ZIP vs 7Z vs RAR: Which Archive Format Should You Use?, UniversalZip](https://www.universalzip.com/articles/zip-vs-7z-vs-rar/)
8. [7zip/DOC/Methods.txt, ip7z/7zip on GitHub](https://github.com/ip7z/7zip/blob/main/DOC/Methods.txt)
9. [The use of cryptography in 7-zip, Josef Hušek, Czech Technical University thesis](https://dspace.cvut.cz/bitstream/handle/10467/83024/F8-BP-2019-Husek-Josef-thesis.pdf)
10. [7zip/DOC/7zFormat.txt, ip7z/7zip on GitHub](https://github.com/ip7z/7zip/blob/main/DOC/7zFormat.txt)
11. [libarchive: Multi-format archive and compression library, GitHub](https://github.com/libarchive/libarchive)
12. [.7z format specification, py7zr documentation](https://py7zr.readthedocs.io/en/stable/archive_format.html)
13. [Best free WinZip alternative of 2025, TechRadar](https://www.techradar.com/best/free-winzip-alternative)
14. [RAR vs ZIP vs 7z: Which Format Should You Use?, Docuboxer](https://www.docuboxer.com/en/blog/rar-vs-zip-vs-7z)
15. [Comparison of Archive Formats, SCIFIC 2024 proceedings, National Aerospace University KhAI repository](https://dspace.library.khai.edu/xmlui/bitstream/handle/123456789/8384/SCIFIC-2024.pdf?isAllowed=y&sequence=1)
16. [New 7-Zip high-severity vulnerabilities expose systems to remote attackers, Tom's Hardware](https://www.tomshardware.com/tech-industry/cyber-security/7-zip-flaws-open-door-to-remote-code-execution)
17. [It's probably time to update 7-Zip, PC Gamer](https://www.pcgamer.com/software/security/its-probably-time-to-update-7-zip-as-the-app-has-just-been-patched-to-fix-a-pretty-big-vulnerability/)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Data formats and serialization › Text, encodings, and archives

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/7z

English original: https://www.edgepedia.org/7z
