Skip to content

Created DiffieHellman.java and MonoAlphabetic.java #5508

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

Merged
merged 77 commits into from
Oct 22, 2024

Conversation

riti2601
Copy link
Contributor

@riti2601 riti2601 commented Oct 1, 2024

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.

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

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 65.51724% with 10 lines in your changes missing coverage. Please review.

Project coverage is 66.97%. Comparing base (5a1f681) to head (338859c).

Files with missing lines Patch % Lines
...java/com/thealgorithms/ciphers/MonoAlphabetic.java 66.66% 4 Missing and 2 partials ⚠️
.../java/com/thealgorithms/ciphers/DiffieHellman.java 63.63% 2 Missing and 2 partials ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@riti2601 riti2601 changed the title Created DiffieHellman.java Created DiffieHellman.java and MonoAlphabetic.java Oct 1, 2024
Copy link
Member

@vil02 vil02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the main methods and add proper junit tests. Prefer ParameterizedTests.

Copy link
Contributor Author

@riti2601 riti2601 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vil02,
I have made the necessary changes according to your suggestions.
Thank you for your valuable feedback!

@riti2601 riti2601 requested a review from vil02 October 7, 2024 12:45
@siriak
Copy link
Member

siriak commented Oct 10, 2024

@vil02 please review

@riti2601
Copy link
Contributor Author

Hi @vil02, kindly review the changed code.

@riti2601
Copy link
Contributor Author

riti2601 commented Oct 22, 2024

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

@siriak siriak dismissed vil02’s stale review October 22, 2024 18:13

Because he is not responding

@siriak siriak enabled auto-merge (squash) October 22, 2024 18:13
@siriak siriak merged commit c56d282 into TheAlgorithms:master Oct 22, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

4 participants