Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions utilities/Caesar-Cipher/Caesar-Cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,23 @@ def main() -> None:

elif choice in ["E", "ENCRYPT", "D", "DECRYPT"]:
message = input("📝 Enter your message: ")


if not message.strip():
print("❌ Error: Message cannot be empty.\n")
continue

non_alpha = sum(1 for c in message if not (c.isascii() and c.isalpha()))
if non_alpha > 0:
print(f"⚠️ Warning: {non_alpha} non-alphabetic character(s) will be left unchanged.\n")

try:
shift = int(input("🔑 Enter the shift key (whole number): "))
except ValueError:
print("❌ Error: Shift key must be a valid whole number.\n")
continue

result = caesar_cipher(message, shift, choice)

print("\n✨ Resulting Message:")
print(f"👉 {result}\n")

Expand Down
Loading