Commit Graph

1 Commits

Author SHA1 Message Date
Dheeraj Kumar
c06dc292fe feat(ciphers): Add PermutationCipher implementation(enhance #6697) (#6700)
* feat(ciphers): Add PermutationCipher implementation with comprehensive tests

- Implement PermutationCipher class for transposition encryption/decryption
- Add encrypt() and decrypt() methods with permutation key support
- Include robust key validation (1-based positions, no duplicates)
- Implement automatic padding for incomplete blocks using 'X' character
- Add comprehensive error handling with descriptive exceptions
- Create 20+ JUnit test cases covering encryption, decryption, edge cases
- Support various key sizes and text processing (spaces removal, case handling)
- Include detailed JavaDoc documentation with algorithm explanation

Algorithm Details:
- Divides plaintext into blocks based on key length
- Rearranges characters within each block according to permutation positions
- Supports round-trip encryption/decryption with inverse permutation
- Handles edge cases: empty strings, single character keys, padding

Tests include: basic functionality, different key sizes, error validation,
real-world examples, and edge case handling.

* Run PermutationCipherTest using Maven

* refactor(PermutationCipher): clean up code by removing unnecessary whitespace and comments

* fix(tests): remove unnecessary whitespace in test assertion for encryption

* fix(tests): correct indentation in assertion for encryption verification

---------

Co-authored-by: a <alexanderklmn@gmail.com>
2025-10-08 08:42:58 +02:00