Git Product home page Git Product logo

steganography's Introduction

Build Status Build Status Build status Crates.io Crates.io Docs.rs dependency status

steganography

A stable steganography library written in rust

Crates.io

Usage

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

[dependencies]
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
                                    })
                                    .collect();
//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

Testing

cargo test -- --test-threads=1

steganography's People

Contributors

teovoinea avatar lucasmw avatar azure-pipelines[bot] avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.