Python Forum
Password Encryption Help Python3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Password Encryption Help Python3
#1
I am trying to make a program that is given a password and encrypts it by shifting each value up by 3. For example, if you entered in the password: Ab1 you would get De4. I'm trying to make it to where if the input is Z or 9, the output loops back to the start. So the password for Z9 would be C3.
I know I need to have a loop in order to accomplish this, but I'm not sure which type of loop/where to put the loop.


Quote:
def caesar(text):
    ciphertext=""
    for char in text:
        if char.isupper():
            ciphertext += chr((ord(char)+3 -65)%+26+65)
        elif char.islower():
            ciphertext += chr((ord(char)+3-97)%26+97)
        elif char.isdigit():
            ciphertext += chr((ord(char)+3))
        else:
            ciphertext+=char
    return ciphertext
text = input("Enter a password: ")
print('Plain Text: ', text)
print('Cipher:', caesar(text))
Quote:
Reply


Messages In This Thread
Password Encryption Help Python3 - by SockMankey - Oct-13-2020, 04:28 PM
RE: Password Encryption Help Python3 - by DPaul - Oct-14-2020, 06:22 AM
RE: Password Encryption Help Python3 - by perfringo - Oct-14-2020, 10:51 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020