Skip to content
A simple steganography library written in rust
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
benches Benchmarking (#10) Sep 10, 2018
examples 1.0.0 Module Refactor (#2) Sep 18, 2017
src Update image requirement from 0.19.0 to 0.21.0 (#14) Jan 14, 2019
tests 1.0.0 Module Refactor (#2) Sep 18, 2017
Cargo.toml bump minor version (#16) May 2, 2019
LICENSE Initial commit Apr 18, 2017 Set up CI with VSTS Pipelines (#11) Sep 13, 2018
_config.yml Set theme jekyll-theme-tactile Jul 6, 2017
appveyor.yml Add appveyor to CI (#4) Nov 26, 2017
vsts-ci.yml Set up CI with VSTS Pipelines (#11) Sep 13, 2018

Build Status Build Status Build status dependency status


A stable steganography library written in rust


Add the following to the Cargo.toml in your project:

steganography = "*"

and import using extern crate:

extern crate steganography;

use steganography::encoder::*;
use steganography::decoder::*;
use steganography::util::*;

Writing a message to a file

//Define a secret message to hide in out picture
let message = "This is a steganography demo!".to_string();
//Convert our string to bytes
let payload = str_to_bytes(&message);
//Load the image where we want to embed our secret message
let destination_image = file_as_dynamic_image("example.jpg".to_string());
//Create an encoder
let enc = Encoder::new(payload, destination_image);
//Encode our message into the alpha channel of the image
let result = enc.encode_alpha();
//Save the new image
save_image_buffer(result, "hidden_message.png".to_string());

Reading a message from a file

//Load the image with the secret message
let encoded_image = file_as_image_buffer("examples/decode_message.png".to_string());
//Create a decoder
let dec = Decoder::new(encoded_image);
//Decode the image by reading the alpha channel
let out_buffer = dec.decode_alpha();
//If there is no alpha, it's set to 255 by default so we filter those out
let clean_buffer: Vec<u8> = out_buffer.into_iter()
                                    .filter(|b| {
                                        *b != 0xff_u8
//Convert those bytes into a string we can read
let message = bytes_to_str(clean_buffer.as_slice());
//Print it out!
println!("{:?}", message);

Running the examples

cargo build --example example_encode
cargo run --example example_encode
cargo build --example example_decode
cargo run --example example_decode


cargo test -- --test-threads=1
You can’t perform that action at this time.