JavaScript icon indicating copy to clipboard operation
JavaScript copied to clipboard

feat: add Substitution Cipher algorithm and tests

Open mmohamedkhaled opened this issue 7 months ago • 2 comments

Open in Gitpod know more

Describe your change:

  • [x] Add an algorithm

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized.
  • [x] I know that pull requests will not be merged if they fail the automated tests.
  • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [x] All new JavaScript files are placed inside an existing directory.
  • [x] All filenames use the UpperCamelCase (PascalCase) style. There are no spaces in filenames.
  • [x] All new algorithms have a URL in their comments that points to Wikipedia or another similar explanation.
  • [x] All code is tested using Vitest and follows the ES Module syntax.
  • [x] Code is formatted using Prettier.

Summary:

This PR adds a monoalphabetic Substitution Cipher to the ciphers/ directory.

  • Includes substitutionCipherEncryption and substitutionCipherDecryption functions
  • Validates key length and character set
  • Test coverage includes:
    • Encryption
    • Decryption
    • Non-alphabetic character handling
    • Invalid key rejection
  • All tests are passing using Vitest
  • Code formatted with Prettier

📚 Reference: Wikipedia – Substitution Cipher

mmohamedkhaled avatar Apr 04 '25 00:04 mmohamedkhaled