Skip to content

Instantly share code, notes, and snippets.

@ahmed4end
Last active February 7, 2020 23:00
Show Gist options
  • Save ahmed4end/83dfb501a29643cfb03c455ac188b0e1 to your computer and use it in GitHub Desktop.
Save ahmed4end/83dfb501a29643cfb03c455ac188b0e1 to your computer and use it in GitHub Desktop.
txt = "Hello".upper()
alpha = [chr(i) for i in range(65, 91)]
res = []
for i in [txt[i:i+3] for i in range(0, len(txt), 3)]:
for x, y in zip([3, 5, 7], i):res.append(alpha[(ord(y)%65+x)%26])
txt = "".join(res)
print("Encryption: "+txt)
res = []
for i in [txt[i:i+3] for i in range(0, len(txt), 3)]:
for x, y in zip([-3, -5, -7], i):res.append(alpha[(ord(y)%65+x)%26])
print("Decryption: "+"".join(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment