Bob are communicating protects the sender and recipient inaccessible information anyone can know Alice and Bob are communicating protects the message Steganography can be combined with Cryptography @5422m4n /sassman
Result<()> { SteganoCore::encoder() .hide_file("Cargo.toml") .use_carrier_image("resources/plain/carrier-image.png") .write_to("/tmp/image-with-a-file-inside.png") .hide(); SteganoCore::decoder() .use_source_image("/tmp/image-with-a-file-inside.png") .write_to_folder("/tmp/") .unveil(); assert_eq_file_content( "/tmp/Cargo.toml".as_ref(), "Cargo.toml".as_ref(), "Unveiled data did not match the original content”, ); Ok(()) } @5422m4n /sassman
Result<()> { SteganoCore::encoder() .hide_file("Cargo.toml") .use_carrier_image("resources/plain/carrier-image.png") .write_to("/tmp/image-with-a-file-inside.png") .hide(); SteganoCore::decoder() .use_source_image("/tmp/image-with-a-file-inside.png") .write_to_folder("/tmp/") .unveil(); assert_eq_file_content( "/tmp/Cargo.toml".as_ref(), "Cargo.toml".as_ref(), "Unveiled data did not match the original content”, ); Ok(()) } @5422m4n /sassman
{ let mut img = self.carrier.as_mut().unwrap(); let mut dec = LSBCodec::new(&mut img); let buf: Vec<u8> = (&self.message).into(); dec.write_all(&buf[..]) .expect("Failed to hide data in carrier image."); // ... self.carrier .as_mut() .expect("Image was not there for saving.") .save(self.target.as_ref().unwrap()) .expect("Failed to save final image"); self } } @5422m4n /sassman
{ let mut img = self.carrier.as_mut().unwrap(); let mut dec = LSBCodec::new(&mut img); let buf: Vec<u8> = (&self.message).into(); dec.write_all(&buf[..]) .expect("Failed to hide data in carrier image."); // ... self.carrier .as_mut() .expect("Image was not there for saving.") .save(self.target.as_ref().unwrap()) .expect("Failed to save final image"); self } } pub struct Message { pub header: ContentVersion, pub files: Vec<(String, Vec<u8>)>, pub text: Option<String>, } @5422m4n /sassman
{ let mut img = self.carrier.as_mut().unwrap(); let mut dec = LSBCodec::new(&mut img); let buf: Vec<u8> = (&self.message).into(); dec.write_all(&buf[..]) .expect("Failed to hide data in carrier image."); // ... self.carrier .as_mut() .expect("Image was not there for saving.") .save(self.target.as_ref().unwrap()) .expect("Failed to save final image"); self } } @5422m4n /sassman
-> Result<usize> { let carrier = &mut self.subject; let (width, height) = carrier.dimensions(); let mut bit_iter = BitReader::endian( Cursor::new(buf), LittleEndian, ); let mut bits_written = 0; for x in 0..width { for y in 0..height { let image::Rgba(mut rgba) = carrier.get_pixel(x, y); for c in 0..3 as usize { rgba[c] = bit_wave(rgba[c], bit_iter.read_bit()); bits_written += 1; } carrier.put_pixel(x, y, Rgba(rgba)); } } Ok((bits_written / 8) as usize) } } @5422m4n /sassman
-> Result<usize> { let carrier = &mut self.subject; let (width, height) = carrier.dimensions(); let mut bit_iter = BitReader::endian( Cursor::new(buf), LittleEndian, ); let mut bits_written = 0; for x in 0..width { for y in 0..height { let image::Rgba(mut rgba) = carrier.get_pixel(x, y); for c in 0..3 as usize { rgba[c] = bit_wave(rgba[c], bit_iter.read_bit()); bits_written += 1; } carrier.put_pixel(x, y, Rgba(rgba)); } } Ok((bits_written / 8) as usize) } } @5422m4n /sassman