GithubHelp home page GithubHelp logo

xor-cipher-cracker's Introduction

xor-cipher-cracker

An attack on the repeating key XOR Cipher. The script attempts to decipher messages encrypted using the XOR Cipher with a repeating key.

Example Usage

example.py shows an example of using xor_cipher_cracker.py to decrypt the contents of secret.hex.

Running example.py

python example.py secret.hex

Methodology

The program works by running through a range of key lengths, slicing out sequential sections of the ciphertext equal in length to each one. The Hamming distance of each two section grouping of the text is then computed. The average Hamming distance for all sections of the ciphertext for each key length are found, and normalised by division by the key length. The smaller the resulting average hamming distance, the more likely a key length is to be correct.

The key space for keys of length n, where n is the most likely key length, is then generated. Each possible key is then XORed with each n-length block of ciphertext, before checking the resulting ASCII value matches one of a list of ‘legal’ characters (’abcdefghijklmnopqrstuvwxyz .,-\’?_()!’). The list of keys that produce only legal characters as the plaintext are then used to fully decrypt the ciphertext, which the program then returns with the corresponding keys.

xor-cipher-cracker's People

Contributors

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