Skip to content

Instantly share code, notes, and snippets.

@Lvl4Sword
Last active December 11, 2020 22:37
Show Gist options
  • Save Lvl4Sword/310c63f3c6d00accc1a8678eed65d5dd to your computer and use it in GitHub Desktop.
Save Lvl4Sword/310c63f3c6d00accc1a8678eed65d5dd to your computer and use it in GitHub Desktop.
Basic concept as to how I believe the 340 Zodiac Cipher would have been done. It could also just be random characters. It's been solved! - https://www.youtube.com/watch?v=-1oQLPRE21o
import string
def encrypt(the_input):
start = 1
encrypted = []
one_e = str.maketrans(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '",
"74IKSQ'VR5LDBZ6J.N1GW?ETO8P UA023F9!MXHYC")
two_e = str.maketrans(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '",
"W1GXAFCQ2YO7VNDZS?K5BUP9T3'I!ERML8H .460J")
three_e = str.maketrans(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '",
"9TL04BN1?MW'GCY758S6 KIJOVPE2UFR!XDAH.ZQ3")
for each in the_input:
if start == 1:
encrypted.append(each.translate(one_e))
start = 2
elif start == 2:
encrypted.append(each.translate(two_e))
start = 3
elif start == 3:
encrypted.append(each.translate(three_e))
start = 1
encrypted_string = "".join(encrypted)
print(encrypted_string)
def decrypt(the_input):
decrypted = []
start = 1
one_d = str.maketrans(
"74IKSQ'VR5LDBZ6J.N1GW?ETO8P UA023F9!MXHYC",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '")
two_d = str.maketrans(
"W1GXAFCQ2YO7VNDZS?K5BUP9T3'I!ERML8H .460J",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '")
three_d = str.maketrans(
"9TL04BN1?MW'GCY758S6 KIJOVPE2UFR!XDAH.ZQ3",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!. '")
for each in the_input:
if start == 1:
decrypted.append(each.translate(one_d))
start = 2
elif start == 2:
decrypted.append(each.translate(two_d))
start = 3
elif start == 3:
decrypted.append(each.translate(three_d))
start = 1
print("".join(decrypted))
if __name__ == "__main__":
while True:
try:
option = int(input("Encrypt(1) or Decrypt(2)?: "))
except ValueError:
print("Options are 1 or 2")
else:
if option in [1,2]:
break
else:
print("Options are 1 or 2")
while True:
verify = []
the_input = input("Only ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!.' and space allowed:\n").upper()
for each in the_input:
if each in "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!.' ":
verify.append(True)
else:
verify.append(False)
if all(verify) is True:
break
else:
print("Try again")
if option == 1:
encrypt(the_input)
elif option == 2:
decrypt(the_input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment