Undergraduate thesis · Chaos theory · Cryptography

Image Encryption Based on Chaotic Logistic Map and LFSR

A grayscale cipher that binds the key to the image itself: pixels are shuffled by a logistic orbit, then drowned in a double diffusion driven by a linear feedback shift register.

Confusion
Logistic map
Diffusion
LFSR + dual pass
Key
Plaintext-dependent

01 — Overview

Two generators. One irreversible-looking field of noise.

The problem

Digital images leak structure. Neighboring pixels are highly correlated, so a weak permutation still looks like a photograph. A useful cipher has to destroy both position and value — then recover both exactly when the key is known.

The approach

The logistic map xn+1 = r xn(1 − xn) at r = 3.99 supplies a chaotic sequence for shuffling. An 8-bit LFSR with taps [7, 5, 4, 3] supplies a bit stream for mixing. Forward and backward diffusion spread a single pixel change across the whole canvas.

The twist

The logistic seed is not a static password. It is offset by the image’s mean intensity, so even a one-pixel edit yields a different orbit — and a different permutation. Decryption stores that sum in catatan_kunci.txt.

02 — Pipeline

From photograph to noise, then back.

Encryption is a one-way walk through six stages. Decryption is the same walk in reverse: undo diffusion, unshuffle, reshape.

  1. 01

    Flatten

    Read grayscale. Rasterize the matrix into a 1-D pixel vector of length N = H × W.

  2. 02

    Bind the seed

    x0 = (0.123456789 + ΣI / 255N) mod 1. A zero seed is replaced by 0.5.

  3. 03

    Chaos orbit

    Iterate the logistic map for N steps. Sort the orbit to obtain a permutation.

  4. 04

    Confusion

    Reorder pixels by that permutation. Spatial neighbors become strangers.

  5. 05

    LFSR stream

    Clock an 8-bit register from seed 0b10101010. Scale bits to 0 or 255.

  6. 06

    Double diffusion

    Forward: ci = (si + ki + ⌊255 xi⌋ + ci−1) mod 256. Then a backward carry pass.

03 — Logistic map

Sensitive dependence, on purpose.

In the chaotic regime the map is deterministic but unpredictable without the exact seed. That orbit becomes the shuffle key: we argsort the sequence and move every pixel to a new index.

  • Parameter r3.99
  • Domainx ∈ (0, 1)
  • UsePermutation / confusion
Orbit · xn+1 = r xn(1 − xn) x₀ = 0.314

04 — Linear feedback

Eight bits, clocked forever.

Each tick XORs taps 7, 5, 4, and 3, shifts the register right, and feeds the result into the MSB. The LSB after the shift is the keystream bit — then multiplied by 255 so it can mix with pixel intensities.

  • Width8-bit
  • Seed0b10101010
  • Taps7 ⊕ 5 ⊕ 4 ⊕ 3
Register · clock out = 0

feedback = b7 ⊕ b5 ⊕ b4 ⊕ b3

05 — Confusion & diffusion

Shuffle the lattice. Then stain every neighbor.

Confusion argsort(chaos)
Double diffusion forward → backward

06 — Live laboratory

Encrypt 256×256 grayscale in the browser.

Same mathematics as the Python thesis code, on a full 256×256 field (65,536 pixels). Drop a photo — it is center-cropped and converted to grayscale — or generate a subject.

Waiting for a source image.

Mean intensity
—
Modified x₀
—
Pixel sum
—
Plaintext
After confusion
Ciphertext
Decrypted

Security notice

Academic implementation.

This cipher was built for research and demonstration. It is not a production cryptosystem. The LFSR is short, the logistic map is floating-point, and the dynamic key must be stored to invert the permutation. Treat it as a study of chaos-based confusion and diffusion — not as a replacement for AES.

View the original algorithm on GitHub