@stegapng/core
v1.1.0
Published
Hide secret data in images
Downloads
2
Readme
About
Stega PNG allows you to hide arbitrary data into the RGBA colorspace data of images.
Read the API documentation.
Install
To use this core library in your JavaScript or TypeScript project, add it to your project's dependencies using your preferred Node package manager:
npm install @stegapng/core
Colorspace Encoding
Since PNG images use lossless compression, it is possible to store invisible data in the least significant bits of the image's RGB (red, green, and blue) colorspace. Alpha (transparency) channels are ignored since using alpha LSBs would often make it trivial to detect the presence of hidden data.
Where To Embed the Bits?
We can configure exactly where secret bits are embedded in the PNG colorspace data, using the best algorithm that fits our requirements.
By default, a linear congruential generator (LCG) allows us to very efficiently choose target pixel channels pseudorandomly on a "full cycle". This means that each pixel channel is picked at most exactly once. Thus, the available space to store data is maximized without needing to generate large arrays of shuffled indices, keep track of "used" channels, etc.
Data Encoding Scheme
StegaV0
Version 0 embraces the KISS approach. The byte-length of the supplied data is encoded into the first 4 bytes, followed by the data itself.
| Segment | Length | Description | |-----------------|---------|--------------------------------------------| | Data Length (L) | 4 bytes | Max 4GB, further limited by the image size | | Data | L bytes | Arbitrary user-supplied data |
The RGBA colorspace index selection is done via a LCG with parameters derived from the RGBA colorspace array itself.