steganography
A stable steganography library written in rust
Usage
Add the following to the Cargo.toml in your project:
[]
= "*"
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;
//Load the image where we want to embed our secret message
let destination_image = file_as_dynamic_image;
//Create an encoder
let enc = new;
//Encode our message into the alpha channel of the image
let result = enc.encode_alpha;
//Save the new image
save_image_buffer;
Reading a message from a file
//Load the image with the secret message
let encoded_image = file_as_image_buffer;
//Create a decoder
let dec = new;
//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: = out_buffer.into_iter
.filter
.collect;
//Convert those bytes into a string we can read
let message = bytes_to_str;
//Print it out!
println!;
Running the examples
Testing