Repository navigation
[R45-T017] Publish runnable worked example and tests for AESEncryption - #57
Open
shyamlibakale1001-alt wants to merge 1 commit into
Open
shyamlibakale1001-alt wants to merge 1 commit into
shyamlibakale1001-alt wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Enhances the class Javadoc of
src/main/java/com/thealgorithms/ciphers/AESEncryption.javawith an executable worked example, intermediate state sizes, the decisiveaesCipher.getIV()state transition, and expected console output; addsAESEncryptionExampleTest.javaexecuting that example and verifying smallest and ordinary inputs; and addswork/R45-T017/check.pyto run and record the checks. All existing behavior and public interfaces are preserved.Related Issue
Fixes: #17
Type of Change
Changes Made
src/main/java/com/thealgorithms/ciphers/AESEncryption.java(lines 20–36) with the runnable worked example (getSecretEncryptionKey()→encryptText("Hello World", secKey)→decryptText(cipherText, secKey)), the decisiveaesCipher.getIV()state transition (12-byte GCM IV + 128-bit authentication tag), and expectedmainoutput. No executable code or public API was altered.src/test/java/com/thealgorithms/ciphers/AESEncryptionExampleTest.javawith 3 test methods (9 logged steps):""→ 16-byte GCM tag / 32 hex chars;"A"→ 17 bytes / 34 hex chars) with round-trip verification and precondition line citations."Hello World", 11 bytes =48656C6C6F20576F726C64in hex) with a fixed 128-bitSecretKeySpec(00000000000000000000000000000000), verifying 27-byte / 54-hex-char ciphertext+tag output, round-trip recovery, and theAEADBadTagExceptioncaused when a subsequentencryptTextcall overwritesaesCipher's IV.AESEncryption.main(new String[0])and asserts all 4 displayed stdout lines (Original Text:Hello World, 32-char hex key, 54-char hex ciphertext,Decryption successful. Decrypted text matches original: true).work/R45-T017/check.py(with evidence files inwork/R45-T017/), runningmvn testforAESEncryptionExampleTest, enforcing a nonzero test count, savingcomparisons.txt,result.txt,mvn_output.txt, andtool_versions.txt, and exiting non-zero on failure.Screenshots / Recordings
Not applicable (no UI changes).
Testing
Command:
python3 work/R45-T017/check.py(runs
mvn -B test -Dtest=AESEncryptionExampleTest -Dsurefire.failIfNoSpecifiedTests=false)Result:
tests=3 failures/errors=0 skipped=0 records=9 mvn_exit=0,status=PASSExisting suite:
mvn -B test -Dtest=AESEncryptionTest -Dsurefire.failIfNoSpecifiedTests=false→Tests run: 5, Failures: 0, Errors: 0, Skipped: 0(BUILD SUCCESS).Negative check: temporarily changing
aesKeyGenerator.init(128);to256on line 71 causedpython3 work/R45-T017/check.pyto printstatus=FAIL(tests=3 failures/errors=2 skipped=0 mvn_exit=1) and exit non-zero; reverted and re-verified.Style:
mvn -B checkstyle:checkreports0 Checkstyle violations(BUILD SUCCESS).Tool versions and check records are saved in
work/R45-T017/tool_versions.txtandwork/R45-T017/comparisons.txt.Checklist
Additional Notes
Decisive state transition:
encryptTextassigns a newly initializedAES/GCM/NoPaddingCipher(with a fresh random 12-byte IV) to the staticaesCipherfield, anddecryptTextdepends onaesCipher.getIV()from that most recent encryption call.The
work/R45-T017/evidence folder is for coursework review only and should not go into any later upstream PR.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 algorithms include a corresponding test class that validates their functionality.
All new code is formatted with
clang-format -i --style=file path/to/your/file.java