Created
September 2, 2019 17:15
-
-
Save JohnnyJayJay/99188e14861ad7d04fe7c0501a8a5522 to your computer and use it in GitHub Desktop.
vigenere cipher hacking script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def duplicates(vigenere): | |
strings = [] | |
duplicates = set() | |
for index in range(len(vigenere)): | |
string = "" | |
for i in range(3): | |
if index + i < len(vigenere): | |
string += vigenere[index + i] | |
if string in strings: | |
duplicates.add(string) | |
strings.append(string) | |
return duplicates | |
def spacings(vigenere, duplicate): | |
spacings = [] | |
for i in range(vigenere.count(duplicate)): | |
first_occurence = vigenere.index(duplicate) | |
vigenere = vigenere[(first_occurence + 3):] | |
second_occurence = vigenere.find(duplicate) | |
if second_occurence != -1: | |
second_occurence += first_occurence + 3 | |
spacings.append(second_occurence - first_occurence) | |
return spacings | |
def divisors(number): | |
divisors = [] | |
current_divisor = 2 | |
while current_divisor <= number / 2: | |
if number % current_divisor == 0: | |
divisors.add(current_divisor) | |
current_divisor += 1 | |
return divisors | |
encrypted = """ | |
KELXTNAZYXJYVGYNRFWANEWCHZCJVR | |
UHCSEHZAOXKEVSMJVFAAXYIEOANYIN | |
SLXNIZLNMHLRUUHIMUYGYYYRZANYIE | |
ZPCYDGLKYHOQLNMHLAHBYQYAKPZNJS | |
ZIWMANZIHXSUYELPEZZIWMLVLRQJMG | |
KRUZWFLNQNIRPNYQIEJHYASELRNWES | |
OIYWEHJHGFRPORCSHIPEBXEUHUWMQN | |
UCBMEHMEHRMFAELXEUKAMXIFDOUSHR | |
YSUZGUUIWMXIPEFFRQLRMNWGOECSDR | |
YHUWHG | |
""".upper().replace("\n", "") | |
for duplicate in duplicates(encrypted): | |
print(f'{duplicate}: {spacings(encrypted, duplicate)}') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment