#decryption #base64 #enigma #encryption

bin+lib cryptor

Cryptor is encryption machine corresponding to the diversity of algorithms

4 releases

Uses old Rust 2015

0.1.3 May 25, 2017
0.1.2 May 24, 2017
0.1.1 May 21, 2017
0.1.0 May 21, 2017

#2460 in Cryptography

MIT/Apache

25KB
396 lines

Cryptor

MIT / Apache2.0 dual licensed Travis Build Status crates.io Document

Cryptor is encryption machine corresponding to the diversity of algorithms.

Dependencies

Insert to Cargo.toml of your project.

[dependencies]
cryptor = "0.1.3"

or

// Newest version
 cargo add cryptor

// Version specification
 cargo add cryptor@0.1.3

// If not exist on crates.io
 mkdir lib
 cd lib
 git clone https://github.com/atsushi130/Cryptor
 cd ..
 cargo add cryptor --path=lib/cryptor/

Default crypto algorithm

  • Enigma
  • Base64

Usage

Import modules

extern crate cryptor;
use cryptor::cryptor::{ Cryptor, CryptoValue, Algorithm };

Implement structure with this Algorithm trait.

pub trait Algorithm {
    type V: Algorithm;
    fn encrypt(&mut self, character: &char) -> CryptoValue<Self::V>;
    fn decrypt(&mut self, character: &char) -> CryptoValue<Self::V>;
}

Cryptor have member with Algorithm trait. Dependency injection your implemented structure to Cryptor.

let mut cryptor = Cryptor::new(YourAlgorithm);

Return type of encrypt and decrypt method is CryptoValue<YourAlgorithm>.

let encrypted: CryptoValue<YourAlgorithm> = cryptor.encrypt(&string);
println!("encrypted string is {}", encrypted.text);

let decrypted: CryptoValue<YourAlgorithm> = cryptor.decrypt(&string);
println!("decrypted string is {}", decrypted.text);

Run

 cargo build
 cargo run

Test

 cargo test

Change logs

v0.1.3
Defined associated function to builds new Cryptor.

impl<T: Algorithm> Cryptor<T> {
    pub fn new(algorithm: T) -> Self {
        Cryptor {
            algorithm
        }
    }
}

changed usage

let mut cryptor = Cryptor::new(your_algorithm);

LICENSE

This project is dual-licensed under MIT and Apache 2.0.

Dependencies

~390KB