zip

package module
v0.1.126 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: BSD-3-Clause Imports: 42 Imported by: 0

README

Go Advanced ZIP Library

Go Reference

This project is a highly optimized and advanced drop-in replacement for the Go standard library archive/zip.

It combines the stability of the standard library with the best open-source ZIP processing features available in the Go ecosystem into a single, powerful package.

Key Features

  • Drop-in Compatibility: 100% compatible with the archive/zip API. You can safely replace your archive/zip imports with github.com/unxed/zip.

  • High Performance: Uses the blazing-fast klauspost/compress library for DEFLATE and adds native Zstandard (ZSTD) support. Both reading and writing are heavily optimized with buffer pooling.

  • Parallel Archiving & Extraction: A concurrent archiver and extractor (adapted from saracen/fastzip) processes multiple files in parallel, significantly speeding up operations on multi-core systems.

  • Advanced Encryption:

    • WinZip AES (AE-2): Full support for reading and writing AES-encrypted archives (128, 192, and 256-bit).
    • Central Directory Encryption (CDE): Encrypt the archive's metadata (filenames, sizes, etc.), making the list of files completely invisible without the correct password.
  • Broad Compression Support:

    • Built-in Deflate64 (Method 9) decoder, used by Windows for large files.
    • Support for BZIP2, LZMA, and PPMd decompression.
  • In-Place Updates (Updater): Modify existing ZIP files by appending or overwriting entries without performing a full re-compression of the entire archive.

  • Cross-Platform Metadata:

    • Unix: Automatic preservation and restoration of UID/GID, extended timestamps, symlinks, hardlinks, and special files (Devices, FIFOs).
    • Windows: Support for reading and writing NTFS Security Descriptors (ACLs), alongside physical pre-allocation to prevent file fragmentation on NTFS.
  • Safe Extraction & Advanced Policies:

    • Path Traversal Defense: Automatic verification to block symlink directory traversal attacks (such as Zip Slip).
    • MOTW Sanitization: Automatically sanitizes Zone.Identifier (Mark of the Web) streams during extraction.
    • Granular Controls: Options for safe atomic writes (SafeWrites), path component stripping (StripComponents), zero-block sparse extraction (Sparse), file-timestamp touching/skipping (NoTimes), and partial file cleanup on errors (KeepBroken).
  • Legacy Codepage Auto-Detection: Includes the advanced heuristic algorithm from 7-zip and far2l to automatically fix "mojibake" (garbled text) in filenames from legacy archives created on different operating systems.

  • Multi-Volume Support: Transparently read split ZIP archives (e.g., archive.z01, archive.z02, ..., archive.zip).

Usage

1. Standard Drop-in Usage

Simply replace the import path. All existing code for archive/zip will work.

import "github.com/unxed/zip"

// Use exactly like the standard library
r, err := zip.OpenReader("archive.zip")
if err != nil {
	log.Fatal(err)
}
defer r.Close()
// ...
2. High-Speed Multithreaded Archiving

The Archiver provides a high-level API for creating archives from a directory structure concurrently.

package main

import (
	"context"
	"log"
	"os"
	"path/filepath"

	"github.com/unxed/zip"
)

func main() {
	sourceDir := "/path/to/source"

	w, err := os.Create("archive.zip")
	if err != nil {
		log.Fatal(err)
	}
	defer w.Close()

	// Create an archiver with 8 concurrent workers
	archiver, err := zip.NewArchiver(w, sourceDir, zip.WithArchiverConcurrency(8))
	if err != nil {
		log.Fatal(err)
	}
	defer archiver.Close()

	// Gather files to be archived
	files := make(map[string]os.FileInfo)
	filepath.Walk(sourceDir, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		// Skip the root directory itself
		if path != sourceDir {
			files[path] = info
		}
		return nil
	})

	// Archive all files concurrently
	if err := archiver.Archive(context.Background(), files); err != nil {
		log.Fatal(err)
	}

	log.Println("Archiving complete!")
}
3. In-Place Archive Updates

Modify an archive without rewriting it from scratch using the Updater.

f, err := os.OpenFile("archive.zip", os.O_RDWR, 0)
if err != nil {
	log.Fatal(err)
}
defer f.Close()

updater, err := zip.NewUpdater(f)
if err != nil {
	log.Fatal(err)
}

// Overwrite an existing file with new content
w, err := updater.Append("config.json", zip.APPEND_MODE_OVERWRITE)
if err != nil {
	log.Fatal(err)
}
w.Write([]byte(`{"updated": true}`))

if err := updater.Close(); err != nil {
	log.Fatal(err)
}
4. Create an AES-256 Encrypted Archive

Provide a password in the FileHeader to enable strong WinZip-compatible AES encryption.

w, _ := os.Create("secure.zip")
defer w.Close()

zw := zip.NewWriter(w)
defer zw.Close()

fh := &zip.FileHeader{
	Name:        "secret.txt",
	Method:      zip.Deflate,
	Password:    "super-secret-password",
	AESStrength: 3, // 1 for 128-bit, 2 for 192-bit, 3 for 256-bit
}

f, err := zw.CreateHeader(fh)
if err != nil {
	log.Fatal(err)
}
f.Write([]byte("this is top secret data"))
5. Create an "Invisible" Archive (Central Directory Encryption)

Encrypt the archive's file list itself, making it impossible to see the contents without a password.

w, _ := os.Create("stealth.zip")
defer w.Close()

zw := zip.NewWriter(w)
defer zw.Close()

// Encrypt the list of files (the central directory)
zw.SetEncryptCentralDirectory(true, "master-password")

// Note: Individual files can still have their own passwords or be unencrypted.
// Here, we encrypt the file with the same password for simplicity.
fh := &zip.FileHeader{
	Name:     "secret.txt",
	Password: "master-password",
}
f, err := zw.CreateHeader(fh)
if err != nil {
	log.Fatal(err)
}
f.Write([]byte("top secret data"))
6. Reading a Multi-Volume Archive

The library handles split archives automatically. Just open the final .zip file.

// This will transparently read from archive.z01, archive.z02, etc.
r, err := zip.OpenReader("archive.zip")
if err != nil {
	log.Fatal(err)
}
defer r.Close()

// You can now access all files as if it were a single archive
for _, f := range r.File {
	fmt.Println("Found file:", f.Name)
}

Format Extensions

This library extends the standard ZIP format by proposing f4 zip extensions. These extensions provide advanced metadata support while remaining fully standard-compliant (standard ZIP utilities will safely skip them).

See the technical specification in f4zip.md.

TorrentZip Specification

Our implementation is 100% bit-exact compatible with the official C-based trrntzip converter. We have documented the exact technical requirements of the format for future reference.

See the technical specification in torrentzip.md.

Why "f4"?

The name comes from the f4 file manager, a cross-platform asynchronous clone of Far Manager. This library was built to provide f4 with high-fidelity archive support, ensuring that system-specific metadata like ACLs and Xattrs are preserved when moving data between Linux, Windows, and macOS.

License

This project is released under the BSD-3-Clause License. See the LICENSE file for details.

Acknowledgements

This library is inspired by several other open-source zip implementations. Please see CREDITS.md for a detailed list of acknowledgements.

Documentation

Index

Constants

View Source
const (
	Store     uint16 = 0 // no compression
	Deflate   uint16 = 8 // DEFLATE compressed
	Deflate64 uint16 = 9
	BZIP2     uint16 = 12
	LZMA      uint16 = 14
	ZSTD      uint16 = 93 // Zstandard compressed
)

Compression methods.

View Source
const MappedStringMark = '\uFFFE'
View Source
const MappedStringMarkStr = "\uFFFE"

Variables

View Source
var (
	ErrFormat       = errors.New("zip: not a valid zip file")
	ErrAlgorithm    = errors.New("zip: unsupported compression algorithm")
	ErrChecksum     = errors.New("zip: checksum error")
	ErrInsecurePath = errors.New("zip: insecure file path")
)
View Source
var ConfigIncludePlatformMetadata = true

ConfigIncludePlatformMetadata defines if FileInfoHeader should automatically include OS-specific metadata (like UID/GID on Unix). Enabled by default to match system archivers behavior.

View Source
var DisableInsecurePaths bool

DisableInsecurePaths controls whether paths containing ".." or "\" are rejected.

View Source
var ErrArchiveLocked = errors.New("zip: cannot modify archive, it is locked")
View Source
var ErrMinConcurrency = errors.New("concurrency must be at least 1")
View Source
var MaxDecompressionDictSize int64 = 128 << 20

MaxDecompressionDictSize defines the maximum dictionary memory allocation (in bytes) allowed for PPMd and LZMA decompilers to prevent RAM bomb DoS attacks. Defaults to 128 MB.

Functions

func EncapsulateXCryptZip added in v0.1.50

func EncapsulateXCryptZip(finalPath, tempPath, password string) error

EncapsulateXCryptZip is a public wrapper to allow the archiver component to call the internal encapsulateXCryptZip function.

func RegisterCompressor

func RegisterCompressor(method uint16, comp Compressor)

func RegisterDecompressor

func RegisterDecompressor(method uint16, dcomp Decompressor)

Types

type AppendMode

type AppendMode int

AppendMode specifies the way to append new file to existing zip archive.

const (
	// APPEND_MODE_OVERWRITE removes the existing file data and append the new
	// data to the end of the zip archive.
	APPEND_MODE_OVERWRITE AppendMode = iota

	// APPEND_MODE_KEEP_ORIGINAL will keep the original file data and only
	// write the new file data at the end of the existing zip archive file.
	// This mode will keep multiple file with same name into one archive file.
	APPEND_MODE_KEEP_ORIGINAL
)

type Archiver

type Archiver struct {
	// contains filtered or unexported fields
}

func NewArchiver

func NewArchiver(w io.Writer, chroot string, opts ...ArchiverOption) (*Archiver, error)

func (*Archiver) Archive

func (a *Archiver) Archive(ctx context.Context, files map[string]os.FileInfo) (err error)

func (*Archiver) Close

func (a *Archiver) Close() error

func (*Archiver) SetComment added in v0.1.30

func (a *Archiver) SetComment(comment string) error

SetComment sets the global archive comment in the Central Directory.

func (*Archiver) Written

func (a *Archiver) Written() (bytes, entries int64)

type ArchiverOption

type ArchiverOption func(*archiverOptions) error

func WithArchiverBufferSize

func WithArchiverBufferSize(n int) ArchiverOption

func WithArchiverConcurrency

func WithArchiverConcurrency(n int) ArchiverOption

func WithArchiverEncryptCD added in v0.1.22

func WithArchiverEncryptCD(enable bool) ArchiverOption

WithArchiverEncryptCD enables Central Directory Encryption (CDE).

func WithArchiverIncremental added in v0.1.14

func WithArchiverIncremental(b bool) ArchiverOption

WithArchiverIncremental includes a .zip_dumpdir index of all active files for incremental restore.

func WithArchiverLevel added in v0.1.36

func WithArchiverLevel(level int) ArchiverOption

WithArchiverLevel sets the compression level (1-9 for Deflate, 1-4 for ZSTD).

func WithArchiverMethod

func WithArchiverMethod(method uint16) ArchiverOption

func WithArchiverOffset

func WithArchiverOffset(n int64) ArchiverOption

func WithArchiverPassword added in v0.1.22

func WithArchiverPassword(password string) ArchiverOption

WithArchiverPassword sets the password for WinZip AES encryption.

func WithArchiverPathMapping added in v0.1.56

func WithArchiverPathMapping(m map[string]string) ArchiverOption

WithArchiverPathMapping sets the path mapping for logical names in the archive.

func WithArchiverPlatformMetadata

func WithArchiverPlatformMetadata(enable bool) ArchiverOption

WithArchiverPlatformMetadata enables inclusion of local OS metadata (UID/GID) for this archiver instance.

func WithArchiverRecovery added in v0.1.26

func WithArchiverRecovery(pct int, f interface{ Name() string }) ArchiverOption

WithArchiverRecovery устанавливает параметры PAR2 избыточности

func WithArchiverSeekIndex added in v0.1.17

func WithArchiverSeekIndex(chunkSize uint32, continuous bool) ArchiverOption

WithArchiverSeekIndex enables generation of a Seek Index for large files or solid archives.

func WithArchiverSolid added in v0.1.14

func WithArchiverSolid(b bool) ArchiverOption

WithArchiverSolid enables solid ZIP-in-ZIP packaging to achieve maximum compression ratio.

func WithArchiverTorrentZip added in v0.1.25

func WithArchiverTorrentZip(b bool) ArchiverOption

func WithArchiverXattrs added in v0.1.8

func WithArchiverXattrs(b bool) ArchiverOption

WithArchiverXattrs enables archiving of extended attributes (xattrs, POSIX ACLs, SELinux).

func WithStageDirectory

func WithStageDirectory(dir string) ArchiverOption

type Compressor

type Compressor func(w io.Writer) (io.WriteCloser, error)

type Decompressor

type Decompressor func(r io.Reader) io.ReadCloser

type Directory

type Directory struct {
	FileHeader
	// contains filtered or unexported fields
}

func (*Directory) HeaderOffset

func (d *Directory) HeaderOffset() int64

type Extractor

type Extractor struct {
	// contains filtered or unexported fields
}

func NewExtractor

func NewExtractor(filename, chroot string, opts ...ExtractorOption) (*Extractor, error)

func NewExtractorFromReader

func NewExtractorFromReader(r io.ReaderAt, size int64, chroot string, opts ...ExtractorOption) (*Extractor, error)

func (*Extractor) Close

func (e *Extractor) Close() error

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context) (err error)

func (*Extractor) Files

func (e *Extractor) Files() []*File

func (*Extractor) Written

func (e *Extractor) Written() (bytes, entries int64)

type ExtractorOption

type ExtractorOption func(*extractorOptions) error

func WithExtractorChownErrorHandler

func WithExtractorChownErrorHandler(fn func(name string, err error) error) ExtractorOption

func WithExtractorConcurrency

func WithExtractorConcurrency(n int) ExtractorOption

func WithExtractorIncremental added in v0.1.14

func WithExtractorIncremental(b bool) ExtractorOption

WithExtractorIncremental enables processing of .zip_dumpdir headers to remove deleted files during incremental restores.

func WithExtractorKeepBroken added in v0.1.11

func WithExtractorKeepBroken(b bool) ExtractorOption

func WithExtractorKeepNewerFiles added in v0.1.13

func WithExtractorKeepNewerFiles(keep bool) ExtractorOption

WithExtractorKeepNewerFiles prevents overwriting files that are newer on disk (--keep-newer-files)

func WithExtractorKeepOldFiles added in v0.1.13

func WithExtractorKeepOldFiles(keep bool) ExtractorOption

WithExtractorKeepOldFiles prevents overwriting existing files (-k or --keep-old-files)

func WithExtractorMaxFileSize

func WithExtractorMaxFileSize(n int64) ExtractorOption

func WithExtractorMaxRatio

func WithExtractorMaxRatio(n int64) ExtractorOption

func WithExtractorNoTimes added in v0.1.13

func WithExtractorNoTimes(noTimes bool) ExtractorOption

WithExtractorNoTimes prevents restoring original modification times (-m / --touch)

func WithExtractorNumericOwner added in v0.1.14

func WithExtractorNumericOwner(b bool) ExtractorOption

WithExtractorNumericOwner always uses numeric user/group IDs from the archive rather than resolving Uname/Gname (--numeric-owner).

func WithExtractorPassword added in v0.1.22

func WithExtractorPassword(password string) ExtractorOption

WithExtractorPassword sets the password for WinZip AES and CDE decryption.

func WithExtractorSafeWrites added in v0.1.13

func WithExtractorSafeWrites(b bool) ExtractorOption

WithExtractorSafeWrites extracts files atomically by writing to a temporary file and renaming (--safe-writes).

func WithExtractorSparse added in v0.1.13

func WithExtractorSparse(b bool) ExtractorOption

WithExtractorSparse enables extracting files as sparse files by seeking over zero-blocks (-S, --sparse).

func WithExtractorStripComponents added in v0.1.13

func WithExtractorStripComponents(count int) ExtractorOption

WithExtractorStripComponents strips the specified number of leading components from file names on extraction (--strip-components)

func WithExtractorTolerant added in v0.1.15

func WithExtractorTolerant(b bool) ExtractorOption

WithExtractorTolerant allows extraction to continue even if some files are corrupted.

func WithExtractorUnlinkFirst added in v0.1.13

func WithExtractorUnlinkFirst(b bool) ExtractorOption

WithExtractorUnlinkFirst removes existing files prior to extracting over them (-U, --unlink-first).

func WithExtractorXattrs added in v0.1.8

func WithExtractorXattrs(b bool) ExtractorOption

WithExtractorXattrs enables restoration of extended attributes (xattrs, POSIX ACLs, SELinux).

type File

type File struct {
	FileHeader
	// contains filtered or unexported fields
}

func (*File) DataOffset

func (f *File) DataOffset() (offset int64, err error)

func (*File) HeaderOffset added in v0.1.109

func (f *File) HeaderOffset() int64

func (*File) Open

func (f *File) Open() (io.ReadCloser, error)

func (*File) OpenRaw

func (f *File) OpenRaw() (io.Reader, error)

func (*File) OpenSeekable added in v0.1.17

func (f *File) OpenSeekable() (io.ReadSeeker, error)

OpenSeekable returns a ReadSeeker for the file content. It requires a Seek Index (Hidden SOZip or GZIDX) to be present in the archive for compressed files.

type FileHeader

type FileHeader struct {
	Name               string
	Comment            string
	NonUTF8            bool // If set, disables automatic UTF-8 flag encoding
	RecoveryPct        int  // Уровень избыточности PAR2 для всего архива
	RecoveryFile       *os.File
	CreatorVersion     uint16
	ReaderVersion      uint16
	Flags              uint16
	Method             uint16
	Modified           time.Time
	Accessed           time.Time
	Created            time.Time
	ModifiedTime       uint16 // Deprecated
	ModifiedDate       uint16 // Deprecated
	CRC32              uint32
	CompressedSize     uint32 // Deprecated: Use CompressedSize64
	UncompressedSize   uint32 // Deprecated: Use UncompressedSize64
	CompressedSize64   uint64
	UncompressedSize64 uint64
	Extra              []byte
	ExternalAttrs      uint32
	// UNIX attributes
	Uid      int
	Gid      int
	OwnerSet bool
	Uname    string // User name of owner
	Gname    string // Group name of owner
	// Hardlinks & Devices
	Devmajor int64
	Devminor int64
	Linkname string
	// Xattrs
	Xattrs map[string]string
	// NTFS Attributes
	Acl []byte // Windows Security Descriptor (ACL)

	// Seek Index (SOZip / GZIDX Hidden files)
	SeekChunkSize  uint32    // Uncompressed block size (e.g. 1MB)
	SeekIndex      []uint64  // SOZip compressed offsets
	GzidxPoints    []gzPoint // GZIDX stateful points
	SeekContinuous bool      // If true, generate GZIDX instead of SOZip

	// WinZip AES encryption
	Password    string
	AESStrength byte // 1 = 128, 2 = 192, 3 = 256. Defaults to 3 (AES-256) if Password != ""
	Level       int
}

FileHeader describes a file within a ZIP file.

func FileInfoHeader

func FileInfoHeader(fi fs.FileInfo) (*FileHeader, error)

func (*FileHeader) FileInfo

func (h *FileHeader) FileInfo() fs.FileInfo

func (*FileHeader) IsEncrypted

func (h *FileHeader) IsEncrypted() bool

func (*FileHeader) ModTime

func (h *FileHeader) ModTime() time.Time

func (*FileHeader) Mode

func (h *FileHeader) Mode() (mode fs.FileMode)

func (*FileHeader) SetComment added in v0.1.29

func (h *FileHeader) SetComment(comment string)

func (*FileHeader) SetModTime

func (h *FileHeader) SetModTime(t time.Time)

func (*FileHeader) SetMode

func (h *FileHeader) SetMode(mode fs.FileMode)

type MultiVolumeReader added in v0.1.27

type MultiVolumeReader struct {
	// contains filtered or unexported fields
}

MultiVolumeReader joins multiple files into a single virtual ReaderAt/WriterAt stream.

func OpenMultiVolume added in v0.1.27

func OpenMultiVolume(mainPath string, flag int) (*MultiVolumeReader, int64, error)

OpenMultiVolume looks for archive parts (.z01, .z02...) alongside the .zip file

func (*MultiVolumeReader) Append added in v0.1.27

func (m *MultiVolumeReader) Append(data []byte) error

func (*MultiVolumeReader) Close added in v0.1.27

func (m *MultiVolumeReader) Close() error

func (*MultiVolumeReader) ReadAt added in v0.1.27

func (m *MultiVolumeReader) ReadAt(p []byte, off int64) (n int, err error)

func (*MultiVolumeReader) WriteAt added in v0.1.27

func (m *MultiVolumeReader) WriteAt(p []byte, off int64) (n int, err error)

type MultiVolumeWriter added in v0.1.27

type MultiVolumeWriter struct {
	// contains filtered or unexported fields
}

MultiVolumeWriter transparently splits data across multiple files.

func NewMultiVolumeWriter added in v0.1.27

func NewMultiVolumeWriter(mainPath string, splitSize int64) (*MultiVolumeWriter, error)

func (*MultiVolumeWriter) Close added in v0.1.27

func (m *MultiVolumeWriter) Close() error

func (*MultiVolumeWriter) Name added in v0.1.27

func (m *MultiVolumeWriter) Name() string

func (*MultiVolumeWriter) Sync added in v0.1.27

func (m *MultiVolumeWriter) Sync() error

func (*MultiVolumeWriter) Write added in v0.1.27

func (m *MultiVolumeWriter) Write(p []byte) (n int, err error)

type ReadCloser

type ReadCloser struct {
	Reader
	// contains filtered or unexported fields
}

func OpenReader

func OpenReader(name string) (*ReadCloser, error)

func OpenReaderWithPassword added in v0.1.22

func OpenReaderWithPassword(name string, password string) (*ReadCloser, error)

func (*ReadCloser) Close

func (rc *ReadCloser) Close() error

type Reader

type Reader struct {
	File    []*File
	Comment string
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.ReaderAt, size int64) (*Reader, error)

func NewReaderWithPassword added in v0.1.22

func NewReaderWithPassword(r io.ReaderAt, size int64, password string) (*Reader, error)

func (*Reader) Open

func (r *Reader) Open(name string) (fs.File, error)

func (*Reader) RegisterDecompressor

func (r *Reader) RegisterDecompressor(method uint16, dcomp Decompressor)

func (*Reader) SetPassword

func (r *Reader) SetPassword(password string)

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater allows to modify & append files into an existing zip archive without decompress the whole file.

WARNING: In-place updates modify the underlying file directly. If the process crashes, is killed, or encounters a power failure during an operation (especially APPEND_MODE_OVERWRITE or RemoveFile), the archive may be left in a corrupted and unrecoverable state. For mission-critical data, it is recommended to backup the archive before updating.

func NewUpdater

func NewUpdater(rws io.ReadWriteSeeker) (*Updater, error)

NewUpdater returns a new Updater from io.ReadWriteSeeker, which is assumed to have the given size in bytes.

func (*Updater) Append

func (u *Updater) Append(name string, mode AppendMode) (io.Writer, error)

func (*Updater) AppendHeader

func (u *Updater) AppendHeader(fh *FileHeader, mode AppendMode) (io.Writer, error)

func (*Updater) Close

func (u *Updater) Close() error

func (*Updater) Entries

func (u *Updater) Entries() []*FileHeader

func (*Updater) GetComment

func (u *Updater) GetComment() string

func (*Updater) RemoveFile

func (u *Updater) RemoveFile(dirIndex int) (int64, error)

func (*Updater) SetComment

func (u *Updater) SetComment(comment string) error

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(w io.Writer) *Writer

func (*Writer) AddFS

func (w *Writer) AddFS(fsys fs.FS) error

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Copy

func (w *Writer) Copy(f *File) error

func (*Writer) Create

func (w *Writer) Create(name string) (io.Writer, error)

func (*Writer) CreateHeader

func (w *Writer) CreateHeader(fh *FileHeader) (io.Writer, error)

func (*Writer) CreateRaw

func (w *Writer) CreateRaw(fh *FileHeader) (io.Writer, error)

func (*Writer) Flush

func (w *Writer) Flush() error

func (*Writer) RegisterCompressor

func (w *Writer) RegisterCompressor(method uint16, comp Compressor)

func (*Writer) SetComment

func (w *Writer) SetComment(comment string) error

func (*Writer) SetEncryptCentralDirectory

func (w *Writer) SetEncryptCentralDirectory(enable bool, password string)

SetEncryptCentralDirectory enables encryption of the central directory records. This hides file names and metadata from unauthorized users. Requires a password to be set.

func (*Writer) SetOffset

func (w *Writer) SetOffset(n int64)

func (*Writer) SetTorrentZip added in v0.1.25

func (w *Writer) SetTorrentZip(b bool)

SetTorrentZip enables torrentzip compatibility mode. It enforces predictable timestamps, clears extra fields, disables data descriptors, and appends a TORRENTZIPPED- CRC32 comment to the archive.

type XCryptHeader added in v0.1.50

type XCryptHeader struct {
	Version    uint8
	KdfAlgo    uint8
	Cipher     uint8
	Iterations uint32
	Salt       []byte
	IV         []byte
	MAC        []byte
}

F4CryptHeader represents the 93-byte binary header for encrypted streams

func (*XCryptHeader) DeriveKey added in v0.1.50

func (h *XCryptHeader) DeriveKey(password string) []byte

func (*XCryptHeader) Encode added in v0.1.50

func (h *XCryptHeader) Encode() []byte

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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