cryptor 0.1.1

Cryptor is encryption machine corresponding to the diversity of algorithms.
Documentation

Cryptor

MIT licensed Travis Build Status crates.io

Cryptor is encryption machine corresponding to the diversity of algorithms.

Dependencies

Insert to Cargo.toml of your project.

[dependencies]
cryptor = "0.1.0"

or

// Newest version
❯ cargo add cryptor

// Version specification
❯ cargo add cryptor@0.1.0

// 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

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 {
    algorithm: 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);

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

let mut encrypter = Encrypter {
    hash: YourAlgorithm { ... }
};

Return type of encrypt method is EncryptValue<YourAlgorithm>;

let encrypted: EncryptValue<YourAlgorithm> = encrypter.encrypt(&character);
println!("encrypted character is {}", encrypted.text);

Run

❯ cargo build
❯ cargo run

Test

❯ cargo test

LICENSE

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