2 releases

0.1.1 Dec 2, 2023
0.1.0 Jan 14, 2023

#461 in Images

Apache-2.0

35KB
461 lines

Steganography - Hidding Message into Image

github crates.io docs.rs CI Build codecov

steganographyrs is a Rust library that inject a message into an image.

The word steganography means to hide something. The definition is very high level. Hence, it has a variety of ways to accomplish the goal of steganography. This library relies on the least significant bits.

What is Least Significant Bits?

  1. Blog Post about using the least significant bits

Consumer of the Library

Install

cargo add steganographyrs

Consumer of the CLI

You must have some arguments like the mode you want to execute (encrypt, decrypt). If you want to use AES encryption, you need to provide your secret password with -p.

You can see all options by using --help or -h

steganographyrs --help
// or in dev:
cargo run -- help

Hide a String without Encryption in an Image

steganographyrs -e inject -m "My Secret Message" -i testAssets/prestine.png -o out.png
// or in dev:
cargo run -- -e inject -i testAssets/prestine.png -o out.png -m "My Secret Message"

Hide an Encrypted String in an Image

steganographyrs -e inject -p secret -m "My Secret Message" -i testAssets/prestine.png -o out.png
// or in dev:
cargo run -- -e inject -p secret -i testAssets/prestine.png -o out.png -m "My Secret Message"

Hide an String from Standard Input, Encrypt the message into an Image

echo "My Secret Message" | steganographyrs -e inject -p secret -i testAssets/prestine.png -o out.png

Hide an String from an external via by using the Standard Input, Encrypt the message into an Image

cat testAssets/message1.txt | steganographyrs -e inject -p secret -i testAssets/prestine.png -o out.png
// or in dev:
cat testAssets/message1.txt | cargo run -- -e inject -i testAssets/prestine.png -o out.png 

Recover a String in an Image in the Terminal Standard Output

steganographyrs -e extract -i testAssets/image_with_secret_message.png
// or in dev:
cargo run -- -e extract -i testAssets/image_with_secret_message.png

The result is sent into the standard output

Recover an Encrypted String from an Image in the Terminal Standard Output

steganographyrs -e extract -p secret -i testAssets/image_with_secret_message.png
// or in dev:
cargo run -- -e extract -p secret -i testAssets/image_with_secret_message.png

Recover a String from an Image Message into a File

steganographyrs -e extract -p secret -i testAssets/image_with_secret_message.png >> message.txt
// or in dev:
cargo run -- -e extract -p secret -i testAssets/image_with_secret_message.png >> message.txt

Recover an Encrypted String in an Image Message into a File

steganographyrs -e extract -p secret -i testAssets/image_with_secret_message.png >> message.txt
// or in dev:
cargo run -- -e extract -p secret -i testAssets/image_with_secret_message.png >> message.txt

Consumer of the Library?

You use the entry function called steganography and you can choose the option you want to inject and extract a message by encrypting or not your message into an input image to an output message.

use steganographyrs::steganography;
let result = steganography(steganography_option); // Result is an option that is only filled on the extraction

As a Developer of the Library

What to Install?

You need to install the right toolchain:

rustup toolchain install stable
rustup default stable

To perform test coverage you need to install

cargo install grcov
rustup component add llvm-tools-preview

To generate benchmark plots you need to install GnuPlot

sudo apt update
sudo apt install gnuplot

# To confirm that it is properly installed:
which gnuplot

Execute

To get all options using cargo run:

cargo run -- -help

Tests

cargo test

Tests Coverage

You must install few components before running coverage:

cargo install grcov
rustup component add llvm-tools-preview

Then, you can run:

./coverage.sh

Further explanation in the Mozilla grcov website

Documentation

The documentation is generated from the source code using:

cargo doc --open  -document-private-items

Testing CLI

All commands for the user works but instead of using

steganographyrs -e true -p secret -m "My Secret Message" -i testAssets/prestine.png -o out.png

You need to use:

cargo run -- -e true -p secret -m "My Secret Message" -i testAssets/prestine.png -o out.png

Benchmark

cargo bench

Publishing

Test the Cargo Content

cargo package --allow-dirty

Then go to steganographyrs/target/package/ to see the content

Push a new Cargo Package

cargo login
cargo publish --dry-run
cargo publish

Dependencies

~8MB
~121K SLoC