- Notifications
You must be signed in to change notification settings - Fork20.9k
Add ElGamalCipher implementing ElGamal encryption and decryption#7064
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
polasisubash wants to merge12 commits intoTheAlgorithms:masterChoose a base branch frompolasisubash:add-elgamal-encryption
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
Show all changes
12 commits Select commitHold shift + click to select a range
61db75a Add ElGamalCipher implementing ElGamal encryption and decryption algo…
polasisubash84c769d style: fix code format for ElGamalCipher
polasisubashc543588 fix: separate BigInteger declarations to satisfy Checkstyle
polasisubash2b3f8f1 fix: remove redundant main method for PMD compliance
polasisubash90b8a9d fix: remove redundant main method to resolve PMD violation
polasisubash99039c6 Merge branch 'master' into add-elgamal-encryption
polasisubasha7792eb Merge branch 'master' into add-elgamal-encryption
polasisubash9f744c2 Merge branch 'master' into add-elgamal-encryption
polasisubash95ce5e6 Add ElGamalCipher unit tests
polasisubash9391734 Merge branch 'master' into add-elgamal-encryption
polasisubashc71a440 Delete src/test/java/com/thealgorithms/ciphers/ElGamalCipherTest.java
polasisubash9d421bc Merge branch 'master' into add-elgamal-encryption
polasisubashFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Add ElGamalCipher unit tests
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit95ce5e6b30cd133cbd2a12d05f441a20aabcd4db
There are no files selected for viewing
41 changes: 41 additions & 0 deletionssrc/test/java/com/thealgorithms/ciphers/ElGamalCipherTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.thealgorithms.ciphers; | ||
| import static org.junit.jupiter.api.Assertions.*; | ||
| import org.junit.jupiter.api.Test; | ||
| public class ElGamalCipherTest { | ||
| @Test | ||
| void testEncryptThenDecrypt_returnsOriginal() { | ||
| ElGamalCipher elg = new ElGamalCipher(); | ||
| String original = "HelloElGamal123"; | ||
| String encrypted = elg.encrypt(original); | ||
| assertNotNull(encrypted); | ||
| String decrypted = elg.decrypt(encrypted); | ||
| assertEquals(original, decrypted); | ||
| } | ||
| @Test | ||
| void testEncryptedIsDifferentFromOriginal() { | ||
| ElGamalCipher elg = new ElGamalCipher(); | ||
| String encrypted = elg.encrypt("TestData"); | ||
| assertNotEquals("TestData", encrypted); | ||
| } | ||
| @Test | ||
| void testEmptyString() { | ||
| ElGamalCipher elg = new ElGamalCipher(); | ||
| String encrypted = elg.encrypt(""); | ||
| String decrypted = elg.decrypt(encrypted); | ||
| assertEquals("", decrypted); | ||
| } | ||
| @Test | ||
| void testNullInputs() { | ||
| ElGamalCipher elg = new ElGamalCipher(); | ||
| assertThrows(IllegalArgumentException.class, () -> elg.encrypt(null)); | ||
| assertThrows(IllegalArgumentException.class, () -> elg.decrypt(null)); | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.