Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Encrypt and decrypt cryptography in Python? The code I got: def encrypt(text): result = s = 3 # traverse text for i in range(len(text)):

Encrypt and decrypt cryptography in Python?

The code I got:

def encrypt(text): result = "" s = 3 # traverse text for i in range(len(text)): char = text[i]

# Encrypt uppercase characters if (char.isupper()): result += chr((ord(char) + s-65) % 26 + 65)

# Encrypt lowercase characters else: result += chr((ord(char) + s - 97) % 26 + 97)

return result

def decrypt(text): result = "" s = 26-3 # traverse text for i in range(len(text)): char = text[i]

# Decrypt uppercase characters if (char.isupper()): result += chr((ord(char) + s-65) % 26 + 65)

# Decrypt lowercase characters else: result += chr((ord(char) + s - 97) % 26 + 97)

return result

#check the above function text = input("Enter Message Please:")

print("Text : " + text) cipher = encrypt(text) print("Cipher: " + cipher) print("De-Cipher: " + decrypt(cipher))

OUTPUT:

Enter Message Please: Hello People! Text : Hello People! Cipher: KhoorqShrsohr De-Cipher: HellonPeopleo

How do I modify this code to get the following output:

Enter Message Please: Hello People! Text : Hello People! Cipher: Khoorq Shrsohr! De-Cipher: Hello People!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

Language in Context?

Answered: 1 week ago