explode

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: GPL-3.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package explode is for use with the archive/zip package.

Explode was a decompression method authored in 1989 by Phil Katz and used in his MS-DOS compression tool, PKZip v0.91.

It is referred to as ZIP Implode/Explode method 6 and is based on the LZ77 algorithm.

This package was first prompted using Gemini in August 2026 and manually cleaned to be idiomatic and readable.

In October 2026, a major logic design issue was discovered and fixed. The package failed to support sliding dictionaries and instead applied a fixed, hard coded 4K dictionary. This issue went undetected as it was fine for binary data and small text files. However, large dense raw text files being imploded using pkzip, commonly applied a sliding dictionary and subsequently would be scrambled upon being exploded using this package.

In 2020, Jason Summers authored a collection of public domain libraries named oldunzip. In-depth information on Implode was authored by Hans Wennborg in 2021, who programmed the public domain implode.c.

Example

Example demonstrates the basic usage of the package.

package main

import (
	"archive/zip"
	"fmt"
	"hash/crc32"
	"io"
	"path/filepath"

	"github.com/Defacto2/archive/explode"
)

func main() {
	const testdata = "testdata"
	const testFile = "example-i.zip"

	// Register the Explode decompressor with the archive zip package.
	explode.Register()

	name := filepath.Join(testdata, testFile)
	rc, _ := zip.OpenReader(name)
	defer rc.Close()

	for n, f := range rc.File {
		fr, _ := f.Open()
		hasher := crc32.NewIEEE()
		size := int64(f.UncompressedSize64) //nolint:gosec
		_, _ = io.CopyN(hasher, fr, size)

		fmt.Printf("%d. Decompressed method %d: %s, %dB\n"+
			"Stored zip crc32 %x, and copied to buffer: %x\n",
			n+1, f.Method, f.Name, f.UncompressedSize64, f.CRC32, hasher.Sum32())

		fr.Close()
	}
}
Output:
1. Decompressed method 6: I.BIN, 2048B
Stored zip crc32 8314ddd9, and copied to buffer: 8314ddd9

Index

Examples

Constants

View Source
const Explode uint16 = 6 // Method 6: Implode/Explode

Variables

View Source
var (
	ErrCorruptHeader = errors.New("explode: corrupt tree header")
	ErrCorruptStream = errors.New("explode: corrupt compressed stream")
)

Functions

func Register

func Register()

Register the Explode method globally for archive/zip.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL