Need Python Help

219 views
Skip to first unread message

Edward Teach

unread,
Oct 22, 2025, 8:09:38 AMOct 22
to Python GCU Forum
Hello,

I would like to be able to create a Python script that would encode a password with the ROT13 algorithm.  For instance, if my password is "fishing", I would like to encode the password to svfuvat.  Thanks in advance.

------------------------------
Edward Teach

Prateek Singh

unread,
Oct 22, 2025, 8:12:55 AMOct 22
to python-g...@googlegroups.com
😊

--
You received this message because you are subscribed to the Google Groups "Python GCU Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-gcu-for...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/python-gcu-forum/79874707-42c6-4a06-ab99-d6c384f2e4fbn%40googlegroups.com.

Tejveer Tummala

unread,
Oct 22, 2025, 8:16:34 AMOct 22
to python-g...@googlegroups.com

def rot13(text):

    result = []

    for char in text:

        if 'a' <= char <= 'z':  # lowercase letters

            result.append(chr((ord(char) - ord('a') + 13) % 26 + ord('a')))

        elif 'A' <= char <= 'Z':  # uppercase letters

            result.append(chr((ord(char) - ord('A') + 13) % 26 + ord('A')))

        else:

            result.append(char)  # leave non-alphabet characters unchanged

    return ''.join(result)



if __name__ == "__main__":

    password = input("Enter your password: ")

    encoded = rot13(password)

    print(f"Encoded (ROT13): {encoded}")



Ajit Pawar

unread,
Oct 22, 2025, 8:22:57 AMOct 22
to python-g...@googlegroups.com
def rot_encode(password):
result = ""
for char in password:
# For lowercase letters

if 'a' <= char <= 'z':
result += chr((ord(char) - ord('a') + 13) % 26 + ord('a'))
# For uppercase letters

elif 'A' <= char <= 'Z':
result += chr((ord(char) - ord('A') + 13) % 26 + ord('A'))
# For non-alphabetic characters (numbers, symbols, etc.)
else:
result += char
return result

# Example usage
password = "fishing"
encoded = rot13_encode(password)
print(f"Original: {password}")
print(f"Encoded : {encoded}")


Reply all
Reply to author
Forward
0 new messages