What Is Digital Steganography? (LSB Payload)
LSB steganography stores data by changing the least significant bit of selected image color samples. In an 8-bit RGB PNG, one bit per red, green, and blue sample gives a theoretical capacity of three bits per pixel. This method is not encryption or a guarantee of invisibility: editing, conversion, or analysis can expose or destroy the payload.
A tiny pixel change can carry information, but the file around it matters just as much. I treat LSB embedding as a defined data format and file-handling task, not as a feature built into PNG. Reliable recovery depends on agreeing on the payload boundaries, sample order, and exact image workflow.
The safest way to learn is to use an image you own, keep the payload small, and test the saved file from start to finish. The method below explains how capacity works, what can break recovery, and how to check the result.
What LSB steganography means
Least-significant-bit, or LSB, steganography places payload bits in the lowest-value bit of selected image samples. In an 8-bit channel, that bit contributes either zero or one to a value from 0 to 255. Changing it alters the sample by no more than one, but this alone does not make the change invisible or secure.
A pixel is made of color samples. In an 8-bit RGB image, each pixel has red, green, and blue values, each ranging from 0 to 255. The LSB is the last binary digit in a sample. For example, changing a red sample from 100 (binary 01100100) to 101 (01100101) flips only that bit.
To embed data, a program reads payload bits in order and replaces selected image LSBs with those bits. A decoder follows the same order and collects them. PNG does not define this process. Its format is specified by ISO/IEC 15948:2004; LSB embedding is a separate, application-level convention.
That distinction matters. PNG can preserve image samples through lossless encoding, but it does not promise to protect an embedded message. Nor does a small sample change prove the image will look or measure as an ordinary image.
Planning the carrier and payload
A carrier is the image that holds the payload; a payload is the data being stored. Before embedding, define how the decoder will find the payload and read its bits. A fixed format avoids guesswork: specify the length, byte order, color channels, pixel traversal order, and any metadata the decoder needs.
Start with an authorized, locally stored image. Decide how many RGB samples to use and how to walk through them. A simple rule is pixels from left to right, then top to bottom, taking red, green, and blue in that order. The decoder must use the identical rule.
The payload also needs a clear end point. Common options include a fixed-size message or a length field placed before the data. A length field is more flexible, but it consumes capacity. Define its size and byte order, such as a four-byte unsigned length in big-endian order. Include any format marker or other framing bytes in the capacity calculation.
If confidentiality matters, encrypt the payload with a suitable, established cryptographic method before embedding it. Encryption protects the content, not the fact that data may be present. Steganography is not authentication, and it does not guarantee that detection is impossible.
Checking image compatibility and capacity
Capacity is the number of payload bits that fit under the chosen embedding rule. For one LSB in each of the three 8-bit RGB channels, an image of width W and height H holds at most ⌊3WH/8⌋ bytes before framing and other overhead. This is a ceiling, not a recommended payload size.
Confirm the image dimensions, bit depth, and color mode before calculating. The formula assumes 8-bit RGB samples and one embedded bit per red, green, and blue channel. It does not apply unchanged to grayscale, indexed-color, higher-bit-depth, or other image modes. An 8-bit RGBA pixel has an alpha sample too, but using alpha is not required and may cause artifacts or compatibility issues. RGB-only embedding is the conservative example here.
| Image dimensions | RGB pixel count | Theoretical capacity | What to remember |
|---|---|---|---|
| 1024 × 768 | 786,432 | 294,912 bytes, or 288 KiB | Subtract framing and metadata |
| 1920 × 1080 | 2,073,600 | 777,600 bytes, or about 759 KiB | This is not a safe target payload size |
These figures assume all RGB LSBs are available. If a four-byte length field is used, subtract at least four bytes; also subtract any format marker, nonce, authentication tag, or other stored data. Encryption can add overhead, so calculate using the final encrypted payload, not just the original message.
Do not confuse this sample capacity with the PNG file’s compressed size. PNG losslessly compresses image data, and the resulting file size depends on image content. A payload that fits the sample calculation may still change compression behavior or draw attention through statistical analysis.
Embedding LSB data and preserving the file
Embedding means replacing chosen sample LSBs with payload bits, then saving the changed samples in a format that retains them. A dependable workflow checks the image first, applies one specified traversal rule, saves as PNG, and reopens the saved file to decode it. Resizing or lossy conversion can break recovery.
Use this sequence:
- Inspect: Confirm the file is yours to use, and record its dimensions, bit depth, and color mode. Convert only when your workflow explicitly allows it, since conversion may change samples.
- Prepare: Build the complete payload, including length and any metadata. If needed, encrypt it before embedding.
- Check capacity: Compare the final payload length in bytes with the available capacity after all overhead.
- Embed: Convert payload bytes to bits in a defined order. Replace only the chosen RGB sample LSBs, following the agreed pixel and channel order.
- Save: Write a PNG without resizing, palette conversion, or other image edits. Reopen the output rather than assuming that a successful save preserved the intended samples.
A one-bit change can raise or lower an 8-bit sample by at most one. That arithmetic limit does not prove visual or statistical indistinguishability. The result depends on the image, the embedding pattern, and the amount of data.
| Operation after embedding | Likely effect on recovery | Practical decision |
|---|---|---|
| Reopen the unchanged PNG | Should retain the decoded samples | Decode and compare bytes |
| Resize or crop | Changes pixel positions or removes samples | Treat as a new, untested file |
| Convert to indexed color | May map colors to a palette | Avoid for the carrier |
| Save or recompress as JPEG | Lossy changes can alter LSBs | Do not use |
| Screenshot the image | May alter dimensions, color, and samples | Do not expect recovery |
PNG’s lossless compression preserves decoded samples when the image data is retained. It does not make the payload permanent. Editing, resizing, palette conversion, screenshots, or JPEG conversion can alter the samples that carry the bits.
Verifying recovery and limitations
Verification checks whether the saved carrier can return the exact original payload under the stated format rules. Decode the declared length, stop at the defined boundary, and compare recovered bytes with the source bytes. Test the file after the real transfer path, because each edit or service may change the image.
A useful test is not “the image still looks the same.” It is a byte-for-byte comparison between the intended payload and the recovered payload. Keep a checksum or direct comparison in your local test process. Also confirm that the decoder rejects a length that exceeds available capacity rather than reading past the image data.
Worked test case (illustrative). For a 1024 × 768, 8-bit RGB image, the calculation gives 294,912 bytes before overhead. Suppose the format reserves four bytes for a length field. The remaining maximum is 294,908 bytes before any other metadata. A smaller payload leaves unused capacity, but does not make the method undetectable.
Test the actual route the file will take. Opening and resaving it in an image editor, sending it through a service, or changing its format may alter samples. Do not assume that messaging or social-media platforms preserve embedded LSBs. Keep an untouched carrier copy, and verify any received copy independently.
LSB has important limits. It can store data, but it does not authenticate the carrier, encrypt the message, or guarantee concealment from statistical checks. If recovery must survive normal image edits, basic LSB replacement is a poor fit; those edits can change the very sample bits that hold the payload.
Conclusion and FAQ
LSB payloads work only when the embedder and decoder agree on a format and the image samples survive unchanged. Calculate capacity from the image mode, include every framing byte, and verify the saved PNG by recovering and comparing the data. Treat concealment as uncertain, and use encryption separately when confidentiality is needed.
Frequently asked questions
What is an LSB payload in an image?
It is data represented by selected least-significant bits in image samples. A decoder reads those bits using the same channel order, pixel order, and payload boundary rules used during embedding.
How much data can an RGB PNG hold with LSB steganography?
With one LSB in each 8-bit red, green, and blue sample, the theoretical capacity is ⌊3WH/8⌋ bytes. Subtract the length field and all other stored overhead.
Does PNG have built-in steganography?
No. PNG is an image format, not a steganography system. LSB embedding is an application-level technique that changes image samples before they are encoded in a PNG file.
Is LSB steganography encryption?
No. LSB embedding stores bits in samples; it does not by itself make the payload unreadable. Encrypt sensitive content separately with established cryptography.
Will changing an LSB be visually noticeable?
A single 8-bit sample changes by at most one value. That does not guarantee the whole image will look or measure as indistinguishable, especially with large payloads or analysis tools.
Can I use the alpha channel in an RGBA PNG?
You can define a method that uses alpha, but it is not required. Changes may affect transparency or compatibility, so an RGB-only rule is a simpler conservative choice.
Does saving as PNG preserve embedded bits?
PNG uses lossless compression, so an unchanged image’s decoded samples can be retained. Later edits, resizing, color conversion, or screenshots can still alter those samples.
Can I embed an LSB payload in a JPEG?
JPEG is lossy. Saving or recompressing can change sample values and destroy or alter embedded LSB data, so this workflow should use PNG, not JPEG.
How do I know the payload decoded correctly?
Decode the declared payload length and compare the recovered bytes with the original. Test the actual saved file, not only the in-memory image before saving.
Is LSB data undetectable?
No. LSB embedding does not guarantee concealment. Image changes may be detected by visual or statistical analysis, and processing can erase the payload.
(This article was written by one of our staff writers, Garrett Vance. Visit our Meet the Team page.)






