Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This requires a string with no spaces or punctuation and just a straight string this website http://textmechanic.com/text-tools/basic-text-tools/remove-extra-spaces/ followed by this website http://www.striphtml.com/ can do this
- cipher = "PIZZG"
- plaintext = open("plaintext.txt", "r+")
- for i in range(27):
- #Initialize the array
- freqlist = []
- #Shift all the letters in the input
- for a in cipher:
- b = ord(a)
- b -= i
- if b > ord("Z"):
- b -= 26
- elif b < ord("A"):
- b+=26
- freqlist.append(b)
- #Now put the shifted letters back together
- shifted = ""
- for a in freqlist:
- d = chr(a)
- #Append the shifted letter onto our output
- shifted += d
- plaintext.write(" ")
- plaintext.write(str(shifted))
- plaintext.write("\n")
- #After we put the decrypted string back together, print it
- #Note this is outside the letter loops,
- #But still inside the possible shifts loop
- #Thus printing all possible shifts for the given message
- print(shifted)
- plaintext.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement