atsushi130 / cryptor Goto Github PK
View Code? Open in Web Editor NEWCryptor is encryption machine corresponding to the diversity of algorithms.
License: Apache License 2.0
Cryptor is encryption machine corresponding to the diversity of algorithms.
License: Apache License 2.0
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.
version up to 0.1.3
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. 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);
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> { ... }
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.