-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create CaeserCipherDecrypt.py #19
Conversation
Decrypting algorithm that decrypts an encoded string generated by a ceaser cipher. Requires encoded string and key as input.
Reviewer's Guide by SourceryThis PR implements a Caesar cipher decryption algorithm in Python. The implementation handles both uppercase and lowercase letters while preserving non-alphabetic characters. The program takes user input for the encoded string and shift key, then outputs the decoded result. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @dhavalpandey - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider separating the cipher logic from I/O operations by moving the input/output code to a separate main() function. This would improve reusability and testability.
- Add error handling for the key input to handle non-integer inputs gracefully. Currently the program will crash if non-numeric input is provided.
- Replace magic numbers (65, 97) with named constants (ord('A'), ord('a')) to improve code readability and maintainability.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
result = "" | ||
for char in text: | ||
if char.isupper(): | ||
result += chr((ord(char) - key - 65) % 26 + 65) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Replace magic numbers with more readable constants
Consider using ord('A') instead of 65 and ord('a') instead of 97 to make the code more readable and maintainable.
result += chr((ord(char) - key - 65) % 26 + 65) | |
result += chr((ord(char) - key - ord('A')) % 26 + ord('A')) |
Decrypting algorithm that decrypts an encoded string generated by a ceaser cipher. Requires encoded string and key as input.
Summary by Sourcery
New Features: