This is a program that can decrypt the codes that have been encrypted using the algorithm that my previously posted encryption program follows, you just need to enter the encrypted text from that program.
I got a lot of suggestions from people on the encryption post, I have tried to make this program as short as possible (in my efforts), I did not use the method they suggested to shorten functions because I don't want to use it without understanding how it works, I will implement it in my further programs as soon as I understand it...
Thank You for the suggestions on the previous program, it helped me reduce the length of this program by 16 lines.
Please let me know what you think about this program
Python Code :
alphabets = 'abcdefghijklmnopqrstuvwxyz'
def position_in_alphabets(tofind):
for i in range(0,26):
if tofind == alphabets[i]:
position = i+1
break
return position
def decrypt(a):
output = ''
for i in range(0,len(a)):
character = a[i]
z = i+1
y = position_in_alphabets(character)
x = z+y-26
if x>len(alphabets):
x = x % len(alphabets)
alpha = alphabets[x-1]
output += alpha
return output
print ()
print ("NOTE : Please enter just lowercase characters (no special characters) and no spaces")
print ()
given = input("Please enter the word to be decrypted : ")
output = decrypt(given)
print ()
print ("The word which is coded as ",given," is : ",output)
Thank You :)