Java icon indicating copy to clipboard operation
Java copied to clipboard

Created DiffieHellman.java and MonoAlphabetic.java

Open riti2601 opened this issue 1 year ago • 7 comments

Description

This PR implements the Diffie-Hellman Key Exchange and MonoAlphabetic Cipher algorithms.

Key Changes:

  1. Diffie-Hellman Key Exchange:

    • Added DiffieHellman.java under the ciphers directory.
    • The implementation allows two users (Person A and Person B) to securely generate a shared secret key over an insecure channel using large prime numbers and modular arithmetic.
    • The code prompts the users to input their secret numbers and performs the necessary calculations to exchange and compute the shared secret keys.
  2. MonoAlphabetic Cipher:

    • Added MonoAlphabetic.java under the ciphers directory.
    • The implementation allows the user to either encrypt or decrypt data using a predefined substitution cipher, where each letter of the alphabet is replaced with a corresponding letter.
    • The user is prompted to enter the data, and the cipher is applied to return either the encrypted or decrypted result.

Both algorithms are utility classes, with private constructors to prevent instantiation and static methods to handle their respective functionalities.

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized it.
  • [x] All filenames are in PascalCase.
  • [x] All functions and variable names follow Java naming conventions.
  • [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [x] All new code is formatted with clang-format -i --style=file path/to/your/file.java

riti2601 avatar Oct 01 '24 16:10 riti2601

Codecov Report

:x: Patch coverage is 65.51724% with 10 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 66.97%. Comparing base (5a1f681) to head (338859c). :warning: Report is 516 commits behind head on master.

Files with missing lines Patch % Lines
...java/com/thealgorithms/ciphers/MonoAlphabetic.java 66.66% 4 Missing and 2 partials :warning:
.../java/com/thealgorithms/ciphers/DiffieHellman.java 63.63% 2 Missing and 2 partials :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5508      +/-   ##
============================================
- Coverage     66.98%   66.97%   -0.01%     
- Complexity     4523     4530       +7     
============================================
  Files           613      615       +2     
  Lines         16990    17019      +29     
  Branches       3282     3286       +4     
============================================
+ Hits          11380    11398      +18     
- Misses         5160     5166       +6     
- Partials        450      455       +5     

: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.

codecov-commenter avatar Oct 01 '24 16:10 codecov-commenter

I am currently unable to build my code due to the outdated pom.xml file. The dependencies required for the JUnit tests are missing, leading to compilation errors. To proceed with testing and building my changes effectively, I recommend updating the pom.xml file to include the necessary JUnit dependencies.

Please let me know if there's a preferred way to address this issue or if I should modify the code to remove the dependencies temporarily.

Thank you!

riti2601 avatar Oct 02 '24 13:10 riti2601

Did you try to place the tests in the .../src/test/java/com/thealgorithms directory? cf. #5501.

vil02 avatar Oct 02 '24 16:10 vil02

No, I'll try it. Thank you

riti2601 avatar Oct 02 '24 17:10 riti2601

Hi @vil02, I've addressed all the requested changes and updated the pull request accordingly. Could you please review the latest changes at your convenience and let me know if anything else is needed? Thank you!

riti2601 avatar Oct 04 '24 12:10 riti2601

@vil02 please review

siriak avatar Oct 10 '24 20:10 siriak

Hi @vil02, kindly review the changed code.

riti2601 avatar Oct 17 '24 14:10 riti2601

Hello @vil02 @siriak @alxkm @BamaCharanChhandogi @yanglbme I am participating in Hacktoberfest'25 and request that you kindly check the PR for further merging. Thank you

riti2601 avatar Oct 22 '24 14:10 riti2601