symp
symp
  • Python Vigenere Cipher Cracker

    See on Github

    Class

    cpre 331

  • Date

    2020, September

  • Time Taken

    6 hours

Info

The goal of this project was to crack a vigenere cipher with a python script. The script also offers and encrypt and decrypt function. I had a lot of fun breaking this cypher and will do my best to explain how the cracking process works. Within the crack function there is a triple while loop that looks at every substring and checks for multiple instances of the string. When a match is found the distance between the matches is put in an array. Once all matches are found the array of distances are factored producing all possible key lengths. Taking the mode of this array gives us our key length. From there we split the cypher into 5 strings where each character is separated by 5. The most common characters of these strings are mapped to E the most common English letter. Then the shift is reversed giving us a best guess for a key. In this case the function returned MACIC, which is obviously meant to be magic. From there we just run the key and ciphertext through the decrypt function.