Git Product home page Git Product logo

caesarcracker's Introduction

caesarcracker: A Python class for cracking Caesar ciphers

Alt text

caesarcracker is a Python library for statistical cracking of Caesar ciphertext. It goes through all 26 possible shifts of the ciphertext, and determines which shift leads to the highest percentage occurence of words that exist in the wordlist. Searches through the wordlist are case-insensitive.

Note: This is not quite a "pure" Caesar Cipher, as it allows for punctuation and numbers.

Starting

Ciphering begins with instantiation of the CaesarCracker class.

import caesarcracker
cc = caesarcracker.CaesarCracker()
cc.load_wordlist("/usr/share/dict/words")
cc.do_cipher_shift('Hello, World!', 10)

The above code instantiates a new CaesarCracker, loads in the system wordlist (this is the wordlist file on my system and for most Unix systems. Do some investigating if the wordlist fails to load on your computer) and does a Caesar shift of size 10. Shifts and cracks in caesarcracker preserve case as well as punctuation, but of course they word for simple Caesar Ciphers as well:

>>> cc.crack('O cgtz zu skkz cozn eua. Juctyzgoxy. Iusk Grutk!') #complex cipher
'I want to meet with you. Downstairs. Come Alone!'

>>> cc.crack('SKKZ GZ ZCKRBK') #Classic Caesar Cipher
'MEET AT TWELVE'

Current Methods

cc.do_cipher_shift(string, num): Do an alphabet shift of num.

cc.load_wordlist(wordlist_file): Needs to be called before any percentage checking is done. Loads a wordlist file into memory and uses it to match possible plaintext words against.

cc.check_percentage_words(plaintext): Checks the available space-delimited letter groups in the plaintext. Based on the total number of these words, it computes what percentage of words in the text are valid words. This function is used in cc.crack() to determine which of the 26 possible shifts leads to the highest percentage of English words in the plaintext.

cc.crack(ciphertext): Crack a Caesar Cipher ciphertext!

caesarcracker's People

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.