LSB — Least Significant Bit
★★★★★
Comment fonctionne le LSB ?
Le bit de poids faible (LSB = Least Significant Bit) de chaque pixel est modifié. Sur une échelle 0-255, changer 254 en 255 est imperceptible à l'œil. On peut stocker 1 bit par canal de couleur par pixel. Pour une image 800x600 RGB : 800×600×3 = 1,44 million de bits = 180 KB de données cachées.
Lire le LSB en Python
from PIL import Image
img = Image.open("image.png")
bits = []
# Lire le LSB de chaque canal R, G, B
for pixel in img.getdata():
for canal in pixel[:3]: # R, G, B
bits.append(canal & 1) # garder bit 0
# Regrouper en octets
output = bytearray()
for i in range(0, len(bits) - 7, 8):
octet = int("".join(str(b) for b in bits[i:i+8]), 2)
output.append(octet)
print(bytes(output[:200])) Comparer avec l'original
# Si l image originale est disponible :
convert original.png stego.png -compose difference -composite diff.png
# Les zones modifiées apparaissent en blanc
# Ou avec PIL :
from PIL import ImageChops
diff = ImageChops.difference(original, stego)
diff.save("diff.png")