You are on page 1of 1

def encrypt(text, shift):

result = ""
# transverse the plain text
for i in range(len(text)):
char = text[i]
# Encrypt uppercase characters in plain text
if char.isupper():
result += chr((ord(char) + shift-65) % 26 + 65)
# Encrypt lowercase characters in plain text
elif char.islower():
result += chr((ord(char) + shift - 97) % 26 + 97) elif char.isdigit():
result += (int(char) + shift) % 10
else:
result += char
return result

#check the above function


statement = input("Please enter String to Encypt:")
statement = statement.lower()
shift_key = 5
print("Shift pattern : " + str(shift_key))
print("The encrypted sentence is: " + encrypt(statement, shift_key))

You might also like