Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Function that encrypts a sentence
- def encrypt(sentence):
- result = []
- #Encryption algorithm = ASCII value -200
- for letter in sentence:
- l = ord(letter)-200
- result.append(l)
- print("This is your encrypted message!")
- #print encrypted value
- for numbers in result:
- print(numbers,end='') #'end=' enables numbers to be printed on same line
- print(" ",end='')
- print() #leave one line
- decrypt(result)
- #function that decrypts a sentence
- def decrypt(result):
- end_string = ""
- for numbers in result:
- l = int(numbers) #convert characters in l into integer
- l = l + 200
- l = chr(l)
- end_string = end_string + l
- print("Your decrypted message is:")
- print(end_string)
- s = input("Input a message you would like to encrypt: ")
- encrypt(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement