bacon-cipher
An implementation of the Bacon's cipher.
The crate offers codecs that encode / decode and steganographers that hide / reveal encoded messages
Encoding - Decoding
Encode a message to Bacon codes
use CharCodec;
use BaconCodec;
use FromIterator;
// Define a Bacon Codec that encodes using the characters 'A' and 'B'
let codec = new;
// This is the secret to encode
let secret: = "My secret".chars.collect;
// Get the encoded chars
let encoded_chars = codec.encode;
let encoded_string = String from_iter;
assert_eq!;
Decode Bacon codes
use CharCodec;
use BaconCodec;
use FromIterator;
// Define a Bacon Codec that encodes using the characters 'A' and 'B'
let codec = new;
// These are the encoded characters
let encoded_chars: = "ABABBBABBABAAABAABAAAAABABAAAAAABAABAABA".chars.collect;
// Retrieve the decoded chars
let decoded = codec.decode;
let string = String from_iter;
assert_eq!;
Steganography
Disguise a hidden message into a public one
use CharCodec;
use LetterCaseSteganographer;
use ;
use FromIterator;
// Define a Bacon Codec that encodes using the characters 'A' and 'B'
let codec = new;
// Apply steganography based on the case of the characters
let s = new;
// This is the public message in which we want to hide the secret one.
let public_chars: = "This is a public message that contains a secret one".chars.collect;
// This is the message that we want to hide.
let secret_chars: = "My secret".chars.collect;
// This is the public message that contains the secret one
let disguised_public = s.disguise;
let string = String from_iter;
assert!;
Reveal a hidden message from a public one
use CharCodec;
use LetterCaseSteganographer;
use ;
use FromIterator;
// Define a Bacon Codec that encodes using the characters 'A' and 'B'
let codec = new;
// Apply steganography based on the case of the characters
let s = new;
// This is the public message that contains a hidden message
let public_chars: = "tHiS IS a PUbLic mEssAge thaT cOntains A seCreT one".chars.collect;
// This is the hidden message
let output = s.reveal;
let hidden_message = String from_iter;
assert!;
Licence
At your option, under:
- Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (http://opensource.org/licenses/MIT)