Skip to content

Commit

Permalink
Update and rename Python/3.6.3/decrypt.py to Python3/decrypt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lukalafaye authored Dec 19, 2017
1 parent d6f6c24 commit 5eac652
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
11 changes: 0 additions & 11 deletions Python/3.6.3/decrypt.py

This file was deleted.

13 changes: 13 additions & 0 deletions Python3/decrypt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def decrypt(initial, key):
""" Use : decrypt("COWUUDNYXGCJFCQVW", "keyword")
=> 'MESSAGEINCAPITALS'
"""
lkey = len(key)
list1 = [ord(i) for i in key]
list2 = [ord(i) for i in initial]
output = ''
for i in range(len(list2)):
value = (list2[i] - list1[i % lkey]) % 26
output += chr(value + 65)

return output

0 comments on commit 5eac652

Please sign in to comment.