Skip to content

Commit

Permalink
Create decrypt.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lukalafaye authored Dec 17, 2017
1 parent 8ed31df commit dd42969
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Python/3.6.3/decrypt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def decrypt():
initial = input('Give the message to encrypt (CAPITALS - no space or special characters) : ')
key = input('Give the key (lowercase letters - no space or special characters) : ')
lkey = len(key)
numeros1 = [ord(i) for i in key]
numeros2 = [ord(i) for i in initial]
output = ''
for i in range(len(numeros2)):
value = (numeros2[i] - numeros1[i % lkey]) % 26
output += chr(value + 65)
print('The decrypted message is : ' + output)

0 comments on commit dd42969

Please sign in to comment.