Question

1. Write Encrypting function with python that takes key and massage then return encrypted massage. 2....

1. Write Encrypting function with python that takes key and massage then return encrypted massage.
2. Write Decrypting function with pyton that takes key and encrypted massage then return the original massage.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here, a simple example of Caesar cipher is taken to demonstrate the encryption and decryption in python

CODE:

def encrypt(message,key):
    str=""
    for i in range(0,len(message)):
        str+=chr((ord(message[i])+key-97)%26+97)
    return str
def decrypt(message,key):
    str=""
    for i in range(0,len(message)):
        str+=chr((ord(message[i])-key-97)%26+97)
    return str
if __name__=="__main__":
    emessage=encrypt("helloworld",14)
    print("Encrypted message of helloworld",emessage)
    print("Decrypted message of",emessage,"is",decrypt(emessage,14))

Output:

Add a comment
Know the answer?
Add Answer to:
1. Write Encrypting function with python that takes key and massage then return encrypted massage. 2....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT