This encoding is easily detected (data is hidden in the last few bits of every pixel's channel) - do not use for sensitive data.
- To output help info use
-h
- To output license info use
-l - this program is licensed under gpl-3-or-later
Installation
If you have golang installed
go install codeberg.org/oliverd/png-steganography@latest
This will install in GOPATH/bin
Or download the latest binaries from releases
Basic usage
# uses 2 bits per channel, example.png should be in the current directory
png-steganography -i example.png -d "hello" -o hidden.png -b 2* # Encode data to hidden.png using example.png as a base
png-steganography -i hidden.png -b 2* # Decode data in hidden.png
Channel options
# uses 3 bits from the blue channel and 2 bits from the others. Data will be stored in order Blue, Red, Green
png-steganography -i example.png -d "hello" -o hidden.png -b 3,2,2 -c BRG
png-steganography -i hidden.png -b 3,2,2 -c BRG
note * repeats the last values the required times e.g -b 2* is equivalent to -b 2,2* or even -b 2,2,2,2
png-steganography -i example.png -d "48656C6C6F20576F726C640A00" -o hidden.png -b 2* -f hex # -d will use hexadecimal,
png-steganography -i hidden.png -b 2* -f hex # data will be output in hexadecimal
png-steganography -i hidden.png -b 2* # data will be output as a string
Options for -f (these can be used to specify the encoding of -d or the output)
hex: hexadecimal
str: string (Null terminated)
b64: base64
bin: same as string but will ignore NULL
Other options
-a all: decoder will read the last binary data even if it is not a whole byte (if the string mode is used Null will still be respected)
-p padding: how many bits should be skipped in the writable components - in encoding mode these bits will not be changed
-r rounding mode: t: truncate, n: nearest
-t type: what image type do you want to encode/decode color: C32, C64 or grey: G8, G16 or alpha: A8, A16
Faq
Output is gibberish
-b needs to be passed the correct number of bits for each channel
- Check what ordering the channels use for your input image, program default is
RGBA, for example you could change the alpha channel to be first by passing -c ARGB
Only partial output
If the default string mode encounters a null byte it will terminate - You can pass -f bin to prevent this behavior
Illegal base64 data
There needs to be a multiple of 4 characters in base64. Use = to pad
Building
Note: This package only depends on the Go standard library
Clone repo (you need to be your src directory GOPATH/src)
git clone https://codeberg.org/oliverd/png-steganography
cd png-steganography # need to be in directory for following commands
Run your version
go run . -i example.png -d "hello" -o hidden.png -b 2*
go run . -i hidden.png -b 2*
Build and install (command line png-steganography will now use your version)
# -w -s to strip debug symbols, panics will still be readable
go install -ldflags "-w -s" .
Compile to all targets
go install github.com/mitchellh/gox@latest # only need if you don't have gox yet
gox -output "build/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-w -s"
This documentation can be reused under GPL-3-or-later or CC-SA-4.0 - (C) Oliver Day