Image methods Scrambling
Block permutation
Block permutation shuffles an image tile by tile rather than pixel by pixel. It protects less than pixel permutation, but has a quality the other methods lack: it can survive JPEG.
How does block permutation work?
- Cut the image into square tiles of side B (8, 16 or 32 pixels).
- Number the tiles and shuffle that list with a pseudo-random sequence derived from the key.
- Rebuild the image by laying the tiles in the new order.
To decrypt, regenerate the same shuffle and put each tile back. If the image dimensions are not multiples of B, the leftover strip is left in place or padded.
Why does it survive JPEG?
JPEG compresses the image in 8 × 8 pixel blocks, processed independently. If the tiles are 8 pixels (or a multiple) and aligned on that grid, each JPEG block holds a coherent piece of the original image. Compression degrades it as it would have in the normal image, without blending unrelated pixels.
Two caveats:
- chroma subsampling (4:2:0) works on 16 × 16 blocks: use 16-pixel tiles, or turn it off;
- services that resize the image break the alignment, and the scramble with it.
That is why the “JPEG” field of this page says “partly survives”.
What does a block-permuted image look like?
Like a mosaic: each tile remains a recognisable fragment (a bit of sky, an eye, a letter). The smaller the tiles, the less the fragments say, but the bigger the file.
What are the weaknesses of block permutation?
Strengths
- JPEG-compatible, hence shareable on platforms that recompress.
- Fast: a few thousand tiles to move instead of millions of pixels.
- Reasonable file size.
Weaknesses
- Solvable like a jigsaw. The edges of neighbouring tiles continue each other: jigsaw-solving algorithms reassemble images of several thousand tiles without the key.
- Tile content stays readable: a word, a face or a number can fit in one tile.
- Unchanged histogram.
- Few combinations when tiles are large.
How do you recover the image without the key?
For each pair of tiles, measure how well the right edge of one continues the left edge of the other, then assemble step by step starting with the most certain pairs. On an ordinary photo, tiles of 16 pixels or more reassemble almost without error. Below 8 pixels, edges carry too little information and the attack becomes unreliable.
What are the variants of block permutation?
- Tile rotation and flipping — each tile is also rotated or flipped: eight possible orientations, which complicate reconstruction.
- Colour inversion of some tiles, depending on the key.
- Two-level permutation — shuffle the tiles, then the pixels inside each. JPEG resistance is then lost.
- Coefficient permutation — work directly in the JPEG file, shuffling its compressed blocks: no loss, no change of size.
In CipherChronicle
The workbench asks for a key and a tile size (8, 16 or 32 pixels). Strips beyond the grid, on the right and at the bottom, stay in place. Export is PNG; to test JPEG resistance, convert the file without resizing it, using 16-pixel tiles.
Demonstration
The CipherChronicle artwork is encrypted then decrypted right here, in your browser, with the same engine as the workbench. Drag the bar to compare.