Add ElGamalCipher implementing ElGamal encryption and decryption
Description
Added a new class ElGamalCipher.java implementing the ElGamal encryption and decryption algorithm.
Features
- Implements ElGamal public-key encryption system
- Supports key generation using modular arithmetic
- Includes methods for encryption and decryption
- Demonstrates successful decryption of encrypted messages
Example Output
Original: 12345 Encrypted: (c1, c2 values) Decrypted: 12345
Technical Notes
- Implemented under
src/main/java/com/thealgorithms/ciphers/ - Successfully compiled and tested locally using Maven (BUILD SUCCESS)
- Compatible with Java 21
- Code adheres to the project’s structure and conventions
References
- Fixes issue: #13580
- Algorithm based on ElGamal public-key cryptography principles
Checklist
- [x] Code compiles successfully
- [x] Tests passed locally (BUILD SUCCESS)
- [x] Follows project style and structure
- [x] Added clear example output
- [x] Confirmed correct encryption and decryption results
Hi maintainers 👋,
I’ve implemented the ElGamal encryption and decryption algorithm as described in the feature request (#6934).
The code compiles successfully, passes local tests, and follows project conventions.
Looking forward to your review. Thank you! 🙌
Codecov Report
:x: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 78.45%. Comparing base (2c4bf3c) to head (9d421bc).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| .../java/com/thealgorithms/ciphers/ElGamalCipher.java | 0.00% | 15 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #7064 +/- ##
============================================
- Coverage 78.51% 78.45% -0.07%
Complexity 6752 6752
============================================
Files 759 760 +1
Lines 22402 22417 +15
Branches 4400 4400
============================================
- Hits 17589 17587 -2
- Misses 4108 4124 +16
- Partials 705 706 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
✅ All checks have passed successfully. The implementation follows the existing cipher structure and includes key generation, encryption, and decryption for ElGamal. Kindly review when you get a chance. Thank you! @DenizAltunkapan @alxkm Kindly review this PR when possible. All checks have passed ✅
✅ All checks have passed successfully. The implementation follows the existing cipher structure and includes key generation, encryption, and decryption for ElGamal. Kindly review when you get a chance. Thank you! @DenizAltunkapan @alxkm Kindly review this PR when possible. All checks have passed ✅
✅ All checks have passed successfully. The implementation follows the existing cipher structure and includes key generation, encryption, and decryption for ElGamal. Kindly review when you get a chance. Thank you! @DenizAltunkapan @alxkm
✅ All checks have passed successfully. The implementation follows the existing cipher structure and includes key generation, encryption, and decryption for ElGamal. Kindly review when you get a chance. Thank you! @DenizAltunkapan @alxkm
@polasisubash Please always add a corresponding test class to your implementation