liveBook · Manning

PKCS#7 padding

PKCS#7 padding is a byte-padding scheme in which each appended byte contains the number of padding bytes added to complete a block.

How 2 Manning books explain it

Hacking Cryptography

PKCS#7 padding is a byte-padding scheme in which each padding byte contains the number of padding bytes added to complete a block.

How it is used
Fits plaintext to block-cipher boundaries before encryption and supports unpadding after decryption.
How deep it goes
Defines the byte rule, exact-block behavior, construction, removal, validation, and padding-oracle consequence.
Examples
Uses repeated 0x04 bytes, Go padding functions, and an AES-CBC encrypted-timestamp server.
What you can do after
Build it from scratch with padding, removal, and validation routines while avoiding distinguishable padding errors.

Read how Hacking Cryptography explains PKCS#7 padding →

Real-World Cryptography

PKCS#7 padding appends bytes whose values equal the number of padding bytes required to reach a block boundary.

How it is used
Prepares plaintext for block encryption by extending it to a complete block boundary.
How deep it goes
Explains the padding rule, full-block case, reversibility, and unpadding procedure, but not implementation details.
Examples
Uses eight-byte plaintext padded with eight bytes of value 8, plus a full sixteen-byte padding block.
What you can do after
Apply it when preparing and reversing block-cipher plaintext, including messages already aligned to a block.

Read how Real-World Cryptography explains PKCS#7 padding →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.