Définition
Technique de stéganographie la plus répandue. Le bit de poids faible de chaque composante de pixel RGB est remplacé par un bit du message secret. Une modification de 1 point sur 255 est invisible à l'œil. Capacité : jusqu'à 3 bits par pixel (1 par canal R, G, B).
Points clés
- 01
Le bit de poids faible (bit 0) représente ±1 sur 255 — soit 0,4% de variation, invisible à l'œil nu.
- 02
En RGB, 3 canaux × 1 bit = 3 bits cachés par pixel. Une image 1000×1000 px peut stocker ~375 Ko de payload.
- 03
Détectable par test chi-carré si le taux d'intégration dépasse 30-50%. Les méthodes adaptatives (LSB matching, HUGO) contournent cette limite.
- 04
Format recommandé : PNG ou BMP. Ne jamais resauvegarder en JPEG — la compression lossy détruit les LSB modifiés.
Schéma
lsb.schema
PIXEL RGB ORIGINAL ENCODAGE DU MESSAGE "101"
─────────────────────────────────────────────────────────
Canal R : 200 → 1100100[0] ──► bit "1" → 1100100[1] = 201
Canal G : 145 → 1001000[1] ──► bit "0" → 1001000[0] = 144
Canal B : 89 → 0101100[1] ──► bit "1" → 0101100[1] = 89 (inchangé)
↑
bit du payload
Variation maximale par pixel : Δ = 1/255 ≈ 0.4%
┌───────────────────────────────────────────────┐
│ Seuil de discrimination de l'œil humain : ~5% │
│ → Modification LSB = IMPERCEPTIBLE │
└───────────────────────────────────────────────┘Exemples
Encodage LSB en Python (PIL)Python
from PIL import Image
def encode_lsb(img_path, message, output_path='stego.png'):
img = Image.open(img_path).convert('RGB')
pixels = img.load()
# Convertir le message en bits + marqueur de fin
bits = ''.join(format(ord(c), '08b') for c in message) + '00000000'
idx = 0
for y in range(img.height):
for x in range(img.width):
r, g, b = pixels[x, y]
if idx < len(bits):
r = (r & 0xFE) | int(bits[idx]); idx += 1
if idx < len(bits):
g = (g & 0xFE) | int(bits[idx]); idx += 1
if idx < len(bits):
b = (b & 0xFE) | int(bits[idx]); idx += 1
pixels[x, y] = (r, g, b)
img.save(output_path)
print(f"Message caché dans {output_path}")
encode_lsb('cover.png', 'Message secret', 'stego.png')Décodage LSB en PythonPython
def decode_lsb(stego_path):
img = Image.open(stego_path).convert('RGB')
pixels = img.load()
bits = ''
for y in range(img.height):
for x in range(img.width):
r, g, b = pixels[x, y]
bits += str(r & 1)
bits += str(g & 1)
bits += str(b & 1)
chars = [chr(int(bits[i:i+8], 2)) for i in range(0, len(bits), 8)]
message = ''
for c in chars:
if c == '\0': # marqueur de fin
break
message += c
return messageCatégorieTechnique
LettreL
Termes liés4 termes