wire / wire-format / zip-local-header

ZIP local file header

Each file in a ZIP archive begins with a 30-byte (minimum) local file header: signature 0x04034B50, version needed, flags, compression method, modtime, CRC-32, compressed/uncompressed sizes, filename length, extra field length, then the filename and extra field, then the (possibly compressed) file data.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: ZIP local file header

wire format

spec: PKWARE APPNOTE.TXT (ZIP format)

Each file in a ZIP archive begins with a 30-byte (minimum) local file header: signature 0x04034B50, version needed, flags, compression method, modtime, CRC-32, compressed/uncompressed sizes, filename length, extra field length, then the filename and extra field, then the (possibly compressed) file data.

fieldsizemeaning
Signature4 bytes0x04034B50 ('PK\x03\x04').
Version needed2 bytesMinimum PKZIP version to extract (e.g. 20 = 2.0, 45 = 4.5 with ZIP64).
General purpose bit flag2 bytesBit 0 = encrypted, bit 3 = data descriptor follows, bit 11 = UTF-8 filename, ... .
Compression method2 bytes0 = stored, 8 = DEFLATE, 12 = BZIP2, 14 = LZMA, 98 = PPMd.
Last mod time2 bytesMS-DOS time (5/6/5 bits for hour/min/sec*2).
Last mod date2 bytesMS-DOS date (7/4/5 bits for year-1980/month/day).
CRC-324 bytesCRC-32 of uncompressed data (0 if data descriptor used).
Compressed size4 bytesSize of compressed data (0 if data descriptor used).
Uncompressed size4 bytesSize of uncompressed data (0 if data descriptor used).
Filename length2 bytesLength of the filename that follows.
Extra field length2 bytesLength of the extra field that follows.
FilenamevariableThe file's path/name (UTF-8 if flag bit 11 set).
Extra fieldvariableTagged extra data blocks (ZIP64, Unix uid/gid, NTFS timestamps, ...).

example:

50 4b 03 04 14 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 1c 00 68 65 6c 6c 6f 2e 74 78 74

Local header for 'hello.txt', stored (method 0), empty extra


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/zip-local-header or /wire-format/zip-local-header.json