Skip to content

Instantly share code, notes, and snippets.

@Kaivosukeltaja
Created November 18, 2014 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaivosukeltaja/1f1921dba9e3d3c9f2a6 to your computer and use it in GitHub Desktop.
Save Kaivosukeltaja/1f1921dba9e3d3c9f2a6 to your computer and use it in GitHub Desktop.
n = int(input("Please enter random seed: "))
message = list(raw_input("Please enter message(s): "))
alphabet = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
sequence = ""
decoded = ""
while len(sequence) < 1000:
n = int(str(n * n).replace("0","1")[-4:-1])
sequence = sequence + str(n)
seqindex = 0
for c in message:
if c in alphabet:
decoded += alphabet[(alphabet.index(c)-int(sequence[seqindex]))%(len(alphabet))]
seqindex += 1
else:
decoded += c
print decoded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment