← Cryptography guide

K101 / Encoding and decoding

DEFLATE gzip

DEFLATE gzip RFC 1951 · Survey date 2026-12-05

DEFLATE is a compression format and algorithm known as the compression algorithm used in zlib.

CRYPTOGRAPHY LAB / K101

Cryptography Lab · DEFLATE gzip

Run real computations and inspect intermediate states step by step.

Educational only. Never enter real passwords or secret keys. Computation stays in your browser; input and trace values are not sent to a server. Do not use this implementation in production.

Scope: Limited implementation

Raw DEFLATE (LZ77 + fixed Huffman; no gzip wrapper)

See the scope above for fixed examples, reduced parameters and supported variants. Standard operation names and formulas are retained.

Reference ↗

Open lab →

Definition and overview
DEFLATE is a compression format and algorithm known as the compression algorithm used in zlib. Source document ↗
Classification and reversibility
DEFLATE combines LZ77 and Huffman coding for reversible lossless compression. Source document ↗
Key or secret requirements
Not confirmed in the survey
Operating principle and structure
Splits input into blocks and compresses with LZ77 backreferences and Huffman coding. Source document ↗
Key size, block size and parameters
Arbitrary block size, but uncompressed blocks are limited to 65,535 bytes; LZ77 can refer back up to 32 KiB. Source document ↗
Security strength and recommendation
Not confirmed in the survey
Known attacks and vulnerabilities
Improper implementations may be vulnerable to DoS such as compression bombs. Source document ↗
Standards and certification
RFC 1951 Internet Standard adopted in 1996; gzip/zlib wrappers use RFC 1952/1950 respectively. Source document ↗
Typical uses
gzip file format is used by gzip/tar CLI and HTTP. Source document ↗
Implementations, libraries and tools
Libraries such as libdeflate implement DEFLATE compression/decompression. Source document ↗
Decryption or decoding
DEFLATE is decoded by an inflater (decompressor). Source document ↗
Advantages
Lossless exact restoration and high interoperability through standardization. Source document ↗
Limitations and cautions
Compression-bomb/DoS risks require input-size limits. Source document ↗
Distinguishing encryption, encoding and hashing
Lossless compression/encoding, not encryption providing confidentiality. Source document ↗

Practical examples

Examples are illustrative; they are not execution-tested implementations or operational recommendations.

Example

Compress a file or HTTP body with DEFLATE, optionally wrap it in gzip/zlib for storage/transfer. Receiver checks wrapper and integrity and decompresses original bytes.

Procedure

Compress original bytes and optionally add gzip/zlib wrapper/checksum. Decompress by checking format, inflating and validating checksum/size. Encryption/decryption is separate and keyed.

Scenario

Web servers gzip HTTP responses; backups and logs can be stored compressed. Receivers should impose maximum decompressed size and check integrity, and maintain patched libraries.

Pitfalls and alternatives

Do not mistake gzip for encryption. Limit decompressed size to prevent bombs/DoS; beware recompression of compressed data, and use checksums and patches against corruption/implementation flaws.

References