4 releases
Uses old Rust 2015
0.2.0 | Mar 23, 2017 |
---|---|
0.1.3 | Mar 21, 2017 |
0.1.2 | Mar 19, 2017 |
0.1.1 | Mar 19, 2017 |
#16 in #caesar
8KB
154 lines
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
Contributors
Background
This was inspired by my Caesar Cipher algorithm implentation in Swift used in my iOS application caesarlib
Dependencies
~2.5MB
~32K SLoC