Giter Site home page Giter Site logo

ciphers's Introduction

Ciphers

This is a package in Rust that implements basics encryption algorithms. Details on the the algorithms implemented can be found in this book. Here is the complete list of algos and their respective status of implementation.

Name status
Caesar cipher done
Transposition Cipher done
Affine Cipher to be done
Simple Substitution to be done
Vigenère Cipher done
One-time Pad Cipher to be done
Generate Prime Numbers to be done
Public Key Cipher to be done

Dependencies

num-traits = "0.2.14"

Example of use:

Here is a chunk of wikipedia text:

Input:

Jeffrey Preston Jorgensen was born in Albuquerque, New Mexico, on January 12, 1964, the son of Jacklyn (née Gise) and Theodore Jørgensen. His biological great-grandfather John Jørgensen, born 8 January 1872 on the small island of Samsø, then in Holbæk County, Zealand, today a municipality in the Central Denmark Region, Denmark, immigrated around 1900 to Chicago, where he had a son, Theodore "Ted" John Jorgensen (b. 1917) with his wife, Ida Minnie Jorgensen, who was also born in Denmark. This son was the father of Ted Jorgensen (b. 1944), Jeff Bezos' biological father.[better source needed] At the time of his birth, his mother was a 17-year-old high school student and his father was 19. After completing high school despite challenging conditions, Jacklyn attended night school while bringing baby Jeff along. After his parents divorced, his mother married Cuban immigrant Miguel "Mike" Bezos in April 1968. Shortly after the wedding, Mike adopted four-year-old Jorgensen, whose surname was then changed to Bezos.

encrypting using Caesar cipher with key=8:

mod sub;

use sub::Caesar;
use sub::Translate;
use std::fs;

fn main() {
    let cypher = Caesar {
        key: 8,
    };
    let contents = fs::read_to_string("yourpath/example.txt").unwrap();
    let encrypt_text = cypher.encrypt(&contents);
    let new_file = "yourpath/example.encrypt.txt";
    fs::write(new_file, encrypt_text).unwrap();
}

Output:

rmnnzmg xzmabwv rwzomvamv eia jwzv qv itjcycmzycm, vme umfqkw, wv rivcizg 12, 1964, bpm awv wn rikstgv (vém oqam) ivl bpmwlwzm røzomvamv. pqa jqwtwoqkit ozmib-ozivlnibpmz rwpv røzomvamv, jwzv 8 rivcizg 1872 wv bpm auitt qativl wn aiuaø, bpmv qv pwtjæs kwcvbg, hmitivl, bwlig i ucvqkqxitqbg qv bpm kmvbzit lmvuizs zmoqwv, lmvuizs, quuqozibml izwcvl 1900 bw kpqkiow, epmzm pm pil i awv, bpmwlwzm "bml" rwpv rwzomvamv (j. 1917) eqbp pqa eqnm, qli uqvvqm rwzomvamv, epw eia itaw jwzv qv lmvuizs. bpqa awv eia bpm nibpmz wn bml rwzomvamv (j. 1944), rmnn jmhwa' jqwtwoqkit nibpmz.[jmbbmz awczkm vmmlml] ib bpm bqum wn pqa jqzbp, pqa uwbpmz eia i 17-gmiz-wtl pqop akpwwt abclmvb ivl pqa nibpmz eia 19. inbmz kwuxtmbqvo pqop akpwwt lmaxqbm kpittmvoqvo kwvlqbqwva, rikstgv ibbmvlml vqopb akpwwt epqtm jzqvoqvo jijg rmnn itwvo. inbmz pqa xizmvba lqdwzkml, pqa uwbpmz uizzqml kcjiv quuqozivb uqocmt "uqsm" jmhwa qv ixzqt 1968. apwzbtg inbmz bpm emllqvo, uqsm ilwxbml nwcz-gmiz-wtl rwzomvamv, epwam aczvium eia bpmv kpivoml bw jmhwa.

ciphers's People

Contributors

lffg avatar lucascr91 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.