caesarlib
Caesar cipher capabilities for Rust.
Usage
Add this to your Cargo.toml
:
[dependencies]
caesarlib = "0.2.0"
and this to your crate root:
extern crate caesarlib;
use caesarlib::*;
Methods
// With custom base sequence
// Can look like "ABC...Zabc...z"
custom_encipher(base_seq: &str, offset: u16, message: &str) -> String
custom_decipher(base_seq: &str, offset: u16, message: &str) -> String
// With roman/latin characters
// Looks like the example for custom base sequences
fn encipher(offset: u16, message: &str) -> String;
fn decipher(offset: u16, message: &str) -> String;
// Returns randomly-generated offset and enciphered text
fn rdm_encipher(message: &str) -> (u16, String)
CLI tool
You can try the lib using the caesar-cli
tool:
$ caesarlib --method encipher --offset 87 --text "Carolus Magnus"
Result: lJaXUdb vJPWdb
With Offset: 87
$ caesarlib --method decipher --offset 87 —text "lJaXUdb vJPWdb"
Result: Carolus Magnus
With Offset: 87
$ caesarlib --random --text "Carolus Magnus"
Result: qOfcZig AOUbig
With Offset: 51312
Tests
Enter the caesarlib repository and run: cargo run --verbose
Dependencies
- clap - Command Line Argument Parser for Rust
- rand - A Rust library for random number generators and other randomness functionality.
Contributors
Versioning
SemVer applies for versioning. For the versions available, see the crate
License
This project is licensed under the MIT License - see the LICENSE file for details
Background
This was inspired by my Caesar Cipher algorithm implentation in Swift used in my iOS application caesarlib