python lsb
Hello there!
你好!
In this article, we will understand how to implement Least-Significant Bit Steganography using Python.
在这篇文章中,我们将了解如何实现l使用Python的朝东šignificant B检查隐写术。
什么是隐写术? (WHAT IS STEGANOGRAPHY?)
Steganography is the science that involves communicating secret data in an appropriate multimedia carrier, e.g., image, audio, and video files. It comes under the assumption that if the feature is visible, the point of attack is evident, thus the goal here is always to conceal the very existence of the embedded data.
隐写术是一门涉及在适当的多媒体载体(例如,图像,音频和视频文件)中传输秘密数据的科学。 它是基于以下假设:如果该功能可见,则攻击点显而易见,因此此处的目标始终是隐藏嵌入式数据的存在。
LSB图像密码学 (LSB IMAGE STEGANOGRAPHY)
LSB Steganography is an image steganography technique in which messages are hidden inside an image by replacing each pixel’s least significant bit with the bits of the message to be hidden.
LSB隐写术是一种图像隐写术技术,其中消息被隐藏在图像内部,方法是将每个像素的最低有效位替换为要隐藏的消息位。
To understand better, let’s consider a digital image to be a 2D array of pixels. Each pixel contains values depending on its type and depth. We will consider the most widely used modes — RGB(3x8-bit pixels, true-color) and RGBA(4x8-bit pixels, true-color with transparency mask). These values range from 0–255, (8-bit values).
为了更好地理解,我们将数字图像视为像素的2D阵列。 每个像素包含的值取决于其类型和深度。 我们将考虑使用最广泛的模式-RGB(3x8位像素,真彩色)和RGBA(4x8位像素,真色带透明蒙版)。 这些值的范围是0到255(8位值)。
![Image for post](https://miro.medium.com/max/9999/1*Gu_RomzVTPMEJ1hfKanRBA.png)
We can convert the message into decimal values and then into binary, by using the ASCII Table. Then, we iterate over the pixel values one by one, after converting them to binary, we replace each least significant bit with that message bits in a sequence.
我们可以使用ASCII表将消息转换为十进制值,然后转换为二进制。 然后,我们逐个迭代像素值,将其转换为二进制值后,将每个最低有效位替换为序列中的消息位。
To decode an encoded image, we simply reverse the process. Collect and store the last bits of each pixel then split them into groups of 8 and convert it back to ASCII characters to get the hidden message.
要解码编码的图像,我们只需将过程逆转即可。 收集并存储每个像素