Code Monkey home page Code Monkey logo

cryptor's People

Contributors

atsushi130 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cryptor's Issues

Should define extensible Exception

Unless you define an extensible exception, you can not extend exception of dedicated to user-defined cryption algorithms.

Algorithm trait is defined as follw.

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

If it is as it is, can only predefined exceptions can be issued.

Update documentation link

Update documentation link

version up to 0.1.3

  • Cryptor
  • Base64 algorithm
  • Crates.io documentation badge

Exception Design

Currently don't error handling of A and B, so we need to do that.
The thing to consider is that there is a possibility of Base64 crate and utf8 convertion errors. So should implement automatic conversion to proprietary errors.

enum CryptoError { ... }
impl Display for CryptoError { ... }
impl Error for CryptoErro { ... }

Error of base64 crate is DecodeError.

impl From<DecodeError> for CryptoError { ... }

Error of utf8 convertion is FromUtf8Error.

impl From<FromUtf8Error> for CryptoError { ... }

Define an associated function to builds new Cryptor.

Request

Define an associated function to builds new Cryptor. Associated function injects Algorithm into Cryptor and generates it.

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

before

let cryptor = Cryptor {
    algorithm: Algorithm { ... }
}

after

let cryptor = Cryptor::new(algorithm);

Base64 crypto support

Acceptance conditions

  • Cryptor is able to crypto with base64 algorithm

Design

Design of base64 algorithm implementation is as follows.

struct Base64;
impl Algorithm for Base64 {
    type V = Base64;
    fn encrypt(&mut self, string: &str) -> CryptoValue<Self::V> { ... }
    fn decrypt(&mut self, string: &str) -> CryptoValue<Self::V> { ... }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.