enigma_machine

Crates.ioenigma_machine
lib.rsenigma_machine
version0.1.2
sourcesrc
created_at2017-05-20 16:30:54.954033
updated_at2017-05-21 08:36:00.850069
descriptionThis crate is Enigma Machine corresponding to various character strings.
homepage
repositoryhttps://github.com/atsushi130/EnigmaMachine/
max_upload_size
id15387
size13,333
Atsushi Miyake (atsushi130)

documentation

README

Enigma Machine

MIT licensed crates.io

This crate is Enigma Machine corresponding to various character strings.

Dependencies

Insert to Cargo.toml of your project.

[dependencies]
enigma_machine = "0.1.0"

or

❯ cargo add encrypter

Usage

import

extern crate enigma_machine;

use enigma_machine::{ Enigma, Router, Reflector, Plugboard, SubstitutionTable };
use enigma_machine::{ SUBSTITUTION_TABLE1, SUBSTITUTION_TABLE2, SUBSTITUTION_TABLE3, REFLECTOR, PLUGBOARD };

setup enigma

let mut enimga = Enigma::new(
    vec![
        Router::new(SubstitutionTable::new(SUBSTITUTION_TABLE1.to_vec())),
        Router::new(SubstitutionTable::new(SUBSTITUTION_TABLE2.to_vec())),
        Router::new(SubstitutionTable::new(SUBSTITUTION_TABLE3.to_vec())),
    ],
    Plugboard::new(SubstitutionTable::new(PLUGBOARD.to_vec())),
    Reflector::new(SubstitutionTable::new(REFLECTOR.to_vec()))
);

set routers position.

let positions = "ABC";
enigma.set_positions(positions);

encrypt and decrypt.

let encrypted = enigma.encrypt(&string);
let decrypted = enigma.decrypt(&encrypted);

License

MIT

Commit count: 14

cargo fmt