Hide a Text Message in a PNG Image
Operator: Abdulla Al Fahad. How tools are built and checked
A 1080 x 1080 picture has 3,499,200 colour values, and changing the last bit of each one alters no value by more than 1 out of 255. That is enough room for a message of up to 437,387 bytes, roughly 437,000 English letters, while the picture looks exactly as before. This page does the hiding and the reading: type the text, save the PNG, and later drop the PNG back in to recover it.
The trick has one hard condition. The message lives in the exact pixel values, so it survives only as long as the file stays a lossless PNG.
Treat it as a way to pass a note inside an ordinary-looking picture, or a way to see how steganography works, not as proof that a message cannot be found.
Key features
- Hides UTF-8 text in the lowest 1 or 2 bits of the red, green and blue values of every fully opaque pixel
- Optional password: AES-256-GCM with a key from PBKDF2-SHA256 at 600,000 rounds, a random 16-byte salt and a random 12-byte IV
- Capacity readout in bytes and percent before you save, counting the 44 bytes encryption adds
- Reads the saved PNG back before downloading, so a browser that alters pixels is caught immediately
- Reports how much the picture changed: how many colour values differ, the largest change and PSNR in decibels
- Extract mode shows whether a found message is encrypted and asks for the password only then
How the message is laid into the pixels, and what destroys it
The first 9 bytes, always stored at one bit per value, are a header: the letters CVST, a flag byte saying whether the payload is encrypted, whether it uses 2 bits per value and which PBKDF2 round count made the key (pictures saved before the count was raised to 600,000 still open with their original 250,000), and a 4-byte length. The payload follows at the chosen depth, then a CRC-32 of the payload. Partly transparent pixels are skipped on both sides, because a canvas does not keep their colour exactly, so a picture with a large transparent area holds less.
One bit per value changes each value by at most 1; two bits change it by at most 3. For the same 1080 x 1080 picture the capacity is 437,387 bytes at one bit and 874,778 bytes at two. A 4000 x 3000 photo holds 4,499,987 bytes at one bit. The cover can be a JPG, WEBP, GIF or BMP, but it is decoded and the output is always a new PNG.
How it works
Hiding encodes the text to UTF-8, encrypts it if a password is set, writes header, payload and checksum into the lowest bits in pixel order, encodes a PNG, then decodes that PNG without colour conversion and extracts again; the two payloads must match byte for byte.
Extracting decodes the PNG the same way, reads the header, checks the CRC-32, and decrypts with the typed password. A wrong password fails the GCM authentication tag, so it is reported as wrong rather than returning gibberish.
Common use cases
- A teacher hides a 300-character clue in a 1920 x 1080 wallpaper, which has room for 777,587 bytes at one bit, and pupils recover it by dropping the PNG into the Extract tab.
- A writer hides a 12,000-character chapter draft, encrypted with a passphrase, in a 4000 x 3000 PNG and uses 44 of its 4,499,987 bytes for the encryption overhead.
- A security student hides the same message at 1 bit and at 2 bits and compares the reported PSNR, to see what the extra capacity costs.
- A designer checks that a picture shared through a chat app loses the message: the app recompresses it as JPEG and Extract reports that no message was found.
How to use this tool
- Choose the cover picture, type the message and optionally a password.
- Watch the capacity line; switch to 2 bits if the message does not fit.
- Download the PNG and send it as a file. To read it, open Extract a message and drop the PNG in.
Example
A 1080 x 1080 picture and a short note
Message: Meet at the north gate at 9 (27 bytes)
Once plain at 1 bit per value, once with the password "lantern"What is written
Plain: 27 bytes. The header and note take 72 + 248 = 320 colour values in the first 107 pixels of the top row; on a photo-like cover 169 of them actually change, none by more than 1
Encrypted: 27 + 44 = 71 bytes, 672 values in the first 224 pixels, of which 321 change
Capacity 437,387 bytes, so the plain note uses 0.006 percentCommon pitfalls
Anything that rewrites the pixels removes the message: a JPG save, a messaging app's recompression, a screenshot of the picture, a resize or a colour filter.
Least-significant-bit hiding is well known and statistical tests such as chi-square can flag it. A password protects the text itself, but not the fact that something is hidden.
- Pick a cover with texture, such as foliage or a crowd. A flat sky with a smooth gradient is where changes to the lowest bit are easiest to detect statistically.
- Hide a short message at 1 bit rather than a long one at 2: the payload is written from the first pixels onward, so a message that fills only 1% of the picture changes only the top rows.
Common errors and how to fix them
- "No hidden message was found"
- The picture carries none, or it has been resized, converted or recompressed since. Use the PNG file saved here, not a copy that passed through another app.
- "That password does not open this message"
- The AES-GCM check failed. Passwords are case-sensitive and read as Unicode NFKC, so retype it rather than pasting text with hidden spaces.
- "This browser changed the pixel values while writing the PNG"
- The read-back check failed, which some privacy modes cause by adding noise to canvas pixels. Turn that protection off for this site or use another browser.
Why a password and the hiding are separate protections
The hiding makes the message hard to notice; the password makes it hard to read even when noticed. Without a password anyone who knows the CVST header, or who runs this page's Extract tab on your picture, reads the text immediately. With one, an attacker who finds the data holds only AES-GCM ciphertext with a fresh salt and IV, and each guess costs one 600,000-round key derivation. That slows guessing but does not stop it, so a short or common password can still be found; use a long passphrase.
Frequently asked questions
Can I hide a file, not just text?
No. The page hides text only, because the length field and the capacity readout are built around UTF-8 messages. Encode a small file as text first if you must, and expect it to use more capacity.
Is a 2-bit message visible to the eye?
Each colour value moves by at most 3 of 255, which is far below what the eye separates on a photograph, but it is measurable: the page prints the PSNR so you can compare the two depths on your own picture.
Does the picture's metadata survive?
No. The cover is redrawn on a canvas and written as a new PNG, so EXIF, GPS and colour profiles of the original are not carried over.