7-ZIP Archive Format

The 7z archive format, known for its impressive compression capabilities, is a versatile and popular choice for compressing files and folders. It’s named after its file extension, ‘.7z’ and is widely used due to its ability to reduce file sizes while maintaining data integrity.

About 7Zip Archive Information

7-Zip is a popular open-source file compression and decompression utility, renowned for its high compression ratio and extensive format support. It can create and extract files not only in the 7z format but also in several other formats like ZIP , TAR, GZIP, and more. Additionally, 7-Zip provides strong encryption options, making it a versatile tool for securely compressing, archiving, and protecting data.

7-Zip Archive File Format History Info

The 7z format was created by Igor Pavlov in 1999. It was introduced as an open-source compression format with a primary focus on delivering high compression ratios and strong encryption. Over time, it gained popularity for its efficiency in reducing file sizes and its support for a variety of compression algorithms.

Structure of 7 ZIP Archive

7z archives are structured as collections of compressed files and directories. They feature a well-organized architecture with headers and data streams. This structure allows for efficient extraction of specific files without the need to decompress the entire archive, enhancing the format’s usability. 7z archives can be “solid” and gain better compression ratio combining several files into single block.

7Zip Compression Methods

7z archives offer such compression methods:

  • LZMA (Lempel-Ziv-Markov chain-Algorithm): Known for its excellent compression ratios, LZMA is the default compression algorithm for 7z archives.
  • LZMA2: An improved version of LZMA, offering faster compression and decompression speeds.
  • PPMd (Prediction by Partial Matching): Designed for text compression, PPMd is effective at compressing documents and text-based files.
  • BZip2: This algorithm is useful for compressing large files efficiently.
  • Deflate: A widely used compression method known for its balance between compression ratio and speed.

Users can choose the most suitable compression method based on their specific needs.

7-Zip Archive Supported Operations

Aspose.ZIP supports composition and extraction the most of 7z archives. It extracts the most of archives that can be composed via 7-zip tool. Coder combination can be very tangled – that’s why Aspose.ZIP can’t guarantee decompression of every valid 7z archive. User can compose archive with all of abovementioned methods and encrypt it with strong AES algorithm. With Aspose.ZIP you can same 7z archive split into several volumes.

7Zip - Internal Structure

Within the 7z archive format lies a carefully designed internal structure that is pivotal in its efficiency and versatility. Understanding this structure can shed light on the format’s remarkable capabilities. At the core of a 7z archive is header metadata that stores vital information about the archive’s content. These headers include details like the names and attributes of compressed files and directories, compression methods, and encryption settings. The hierarchical organization of this metadata allows for efficient access to specific files within the archive without the need to decompress everything.

The heart of any compression format is its compressed data streams. In the case of 7z, these streams hold the compressed data for each file and directory within the archive. What makes 7z particularly efficient is its ability to apply different compression methods to individual streams, optimizing compression ratios while minimizing processing time.

The directory structure of a 7z archive resembles the layout of the original files and folders being compressed. This structure includes the hierarchy of directories and their respective files, mirroring the organization of the uncompressed data. It allows for seamless navigation and retrieval of specific files when extracting from the archive.

7z archives may contain optional metadata and recovery records. These elements provide additional functionality, such as file comments, timestamps, and even error recovery capabilities. The latter can be especially valuable, allowing damaged archives to be partially or fully repaired by leveraging the recovery records.

7Zip - Internal Structure

Popularity of 7z Archive and Support

7z archives have gained widespread popularity due to their exceptional compression ratios and open-source nature. They are supported on multiple platforms, including Windows, macOS, and Linux, and can be manipulated using various third-party applications and libraries. As a result, the 7z format is an advanced choice for users seeking efficient compression and secure archiving of files and directories.

Examples of Using 7Z-files

7Z archives are a ubiquitous file format for compressing and organizing data, making them essential in various software applications. Operations with archives via .NET empowers developers to work with Zip-files effortlessly. In the following code examples, we’ll delve into the capabilities of operations with 7Zip archive, demonstrating how to create new 7ZIP file online archives and efficiently extract files from existing ones. These examples will help you harness the capabilities of this library to manage 7z archives seamlessly in your .NET projects

Create a 7-Zip Single Entry

In the code example below, we illustrate the process of generating a 7-Zip entry through the utilization of a SevenZipArchive instance.

    using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
    {
        using (var archive = new SevenZipArchive())
        {
            archive.CreateEntry("data.bin", "file.dat");
            archive.Save(sevenZipFile);
        }
    }

Create 7-Zip Archive Entries

The SevenZipArchive class offers CreateEntries methods for the recursive addition of files and directories within a specified directory. The subsequent code example illustrates the creation of 7-Zip archive entries using these methods.

    using (SevenZipArchive archive = new SevenZipArchive())
    {
        archive.CreateEntries(dataDir);
        archive.Save("SevenZip.7z");
    }

7-Zip Encryption Settings

The Aspose.ZIP API features the SevenZipAESEncryptionSettings class, designed to offer settings for AES encryption and decryption in 7z archives. In the code example below, we demonstrate how to configure AES Encryption Settings for your archives.

    using (var archive = new SevenZipArchive(new SevenZipEntrySettings(null, new SevenZipAESEncryptionSettings("p@s$"))))
    {
        archive.CreateEntry("data.bin", new MemoryStream(new byte[] { 0x00, 0xFF }));
        archive.Save("archive.7z");
    }

Additional information about Zip-archives

People have been asking

1. What is the best compression method in 7-Zip?

The best compression method in 7Z depends on your specific needs. The format and settings you choose should consider factors such as the type of data you’re compressing, the balance between compression ratio and speed, and the compatibility with the tools and software you’ll be using to extract the compressed files. Use PPMd method for text compression. Play with your data to choose with algorithm would provide the best ratio.

2. Is 7Z more secure than zip?

The most robust format is 7Z, with ZIP-AES-256 following closely. In conclusion, when dealing with encrypted files, there is no practical justification for continuing to use the standard ZIP format. We would like to draw your attention to the fact that initializing encryption in the 7z archive takes longer than in ZIP, so it is more difficult to guess the password. Additionally, it is advisable to use a strong and secure password when encrypting the archive.

3. Is 7Z open-source?

Yes, 7Z is an open-source file archiver. It is distributed under the GNU Lesser General Public License (LGPL), which means its source code is freely available for viewing, modification, and distribution by the community. This open-source nature has contributed to its widespread use and popularity as a compression tool.