Crates.io | caesarlib |
lib.rs | caesarlib |
version | 0.2.0 |
source | src |
created_at | 2017-03-19 12:46:14.834917 |
updated_at | 2017-03-23 14:54:13.143923 |
description | A Caesar-Cipher library for Rust. |
homepage | |
repository | https://github.com/caesarlib/caesarlib.rs |
max_upload_size | |
id | 9040 |
size | 11,511 |
Caesar cipher capabilities for Rust.
Add this to your Cargo.toml
:
[dependencies]
caesarlib = "0.2.0"
and this to your crate root:
extern crate caesarlib;
use caesarlib::*;
// 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)
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
This was inspired by my Caesar Cipher algorithm implentation in Swift used in my iOS application caesarlib