Giter Club home page Giter Club logo

classicalciphercrackers's Introduction

ClassicalCipherCracker

A (hopefully) considerably copious collection of classical cipher crackers

Written in Python3 (and run with PyPy)

TODOs

  • Investigate using __slots__ for time/memory optimization
  • Add methods to the cipher objects so that keys can be more quickly mutated
  • Write a word splitter which separates plaintext into words
  • Investigate using AI to identify what cipher a ciphertext might be encrypted with
  • Investigate training a simple AI-like model which can evaluate the english-ness of text

Terminology

  • Plaintext: a message which is readable and unencrypted
  • Ciphertext: a message which is encrypted
  • Decoder/Decrypter: a program which will decrypt a ciphertext when given the key
  • Cracker: a program that can decrypt a ciphertext without the key, usually by making use of the decrypter

Basic Methodology

A cracker has three major components: the key-finding algorithm, the decrypter, and the text evaluator.

The key-finding algorithm will generate keys which will be used by the decrypter to find the plaintext that the key would generate. This plaintext will be tossed into the text evaluator. If it gets a high score, the current key and plaintext will be saved as a possible answer. As more keys get tested, the best key-plaintext pair will be continuously updated.

If the keyspace is small, then every key will be tested. If brute force isn't feasible, a hill-climbing algorithm will be used, where random changes to the key are either kept or dropped if they create a better text evaluation. The goal of the algorithm is to reach a "hill", where the plaintext is as likely to be the real message as possible. To avoid running into local minima (which is a common problem with hill-climbing), random-restart hill climbing (also known as shotgun hill climbing) is used. Simulated annealing may also be used in the future.

Code should be written to prioritize speed when run under PyPy, though it should still be reasonably readable. In particular, decrypters must be optimized to run quickly, as they are often called thousands of times in order to crack a cipher. Different versions of decrypters should be tested and timed to determine which is most performant. The same applies to the text fitness evaluator.

Resources

Text Fitness

http://practicalcryptography.com/cryptanalysis/text-characterisation/quadgrams/
https://medium.com/analytics-vidhya/how-to-distinguish-between-gibberish-and-valid-english-text-4975078c5688
https://planetcalc.com/7959/, https://planetcalc.com/8045/
https://gitlab.com/guballa/SubstitutionBreaker/-/blob/development/subbreaker/breaker.py

Word Splitting

http://practicalcryptography.com/cryptanalysis/text-characterisation/word-statistics-fitness-measure/

classicalciphercrackers's People

Contributors

jonathanuhler avatar qpwoeirut avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.