Skip to content
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

Optimize Caesar Cipher Implementation and Enhance Robustness #2046

Open
Suhaniahirwar20 opened this issue Mar 13, 2025 · 1 comment
Open

Comments

@Suhaniahirwar20
Copy link

Description:
The current Caesar cipher implementation works correctly for both encryption and decryption, but there are opportunities for optimization and added functionality:

Optimization: The getCipherMap function unnecessarily clones the charsMap object in every iteration, which can be simplified by directly updating the existing object.
Robustness: There are no checks for invalid inputs, such as non-string data types or empty strings. Adding input validation will make the functions more reliable.
Preserve Case: The cipher converts all characters to lowercase, losing the original case. Enhancing the logic to preserve the case would improve usability.
Suggested Fix:

Optimize the reduce method by removing redundant cloning.
Add input validation checks.
Implement case-sensitive encryption and decryption.

@lazarljubenovic
Copy link

Are you at least using a premium language model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants