#cipher #classical #crypto

classic_crypto

Encrypt, decrypt and solve classical ciphers with any charset

2 unstable releases

0.2.0 May 21, 2021
0.1.0 Feb 24, 2021

#833 in Cryptography

Custom license

190KB
4K SLoC

classic_crypto

Build Status

A number of classical ciphers implemented in Rust, with the capability to supply a character set for any language.

CLI

There is a CLI available for this library here.

Usage

Add this line to your Cargo.toml

classic_crypto = "0.1.0"

Example

use classic_crypto::{Asymmetric, Caesar, Keyed, Solve, lang::Language};

fn main() {
    let mut language = Language::from_file("examples/data/english.bin").unwrap();
    let mut caesar = Caesar::new(&mut language);

    caesar.randomize(&mut language);

    let plaintext = "Secret message!";
    let ciphertext = caesar.encrypt(&mut language, plaintext);

    caesar.randomize(&mut language);

    caesar.solve(&mut language, &ciphertext);

    let plaintext = caesar.decrypt(&mut language, &ciphertext);
    println!("plaintext {}", plaintext);
}

Supported Ciphers

Name Encrypt/Decrypt Solve
ADFGVX ⬜️ ⬜️
ADFGX ⬜️ ⬜️
Affine
Atbash N/A
Autokey
Baconian N/A
Beaufort
Bellaso
Bifid ⬜️ ⬜️
Block Transposition
Caesar
Chaocipher ⬜️ ⬜️
Classic Vigenère
Clock
Chase
Column Transposition
Enigma M3/M4 ⬜️
Fialka ⬜️ ⬜️
Four Square ⬜️ ⬜️
Fractionated Morse ⬜️ ⬜️
Hill (2x2 and 3x3 matrices) ⬜️ ⬜️
Homophonic Substitution ⬜️ ⬜️
Keyed Vigenère ⬜️
Lorenz ⬜️ ⬜️
Morse N/A
Myszkowski Transposition ⬜️ ⬜️
Playfair ⬜️ ⬜️
Polybius Square ⬜️ ⬜️
Porta
Purple ⬜️ ⬜️
Railfence
Rot13 N/A
Scytale
Simple Substitution
Solitaire ⬜️ ⬜️
Straddle Checkerboard ⬜️ ⬜️
Trifid ⬜️ ⬜️
Two Square ⬜️ ⬜️
Typex ⬜️ ⬜️
VIC ⬜️ ⬜️

Dependencies

~0.9–1.6MB
~34K SLoC