javascript-algorithms icon indicating copy to clipboard operation
javascript-algorithms copied to clipboard

feat: Add a Cryptography Algorithm Playfair cipher

Open Dhvani365 opened this issue 2 months ago • 2 comments

Added Playfair cipher (JavaScript) in Cryptography Algorithms

What: Adds implementation of the Playfair cipher in JavaScript, including encrypt and decrypt functions. Includes README explanation and unit tests.

Why: The repository already includes classical ciphers (Caesar, Rail-Fence, Hill). The Playfair cipher is a historically important digraph substitution cipher and completes this cryptography section.

How:

  • playfairCipher.js contains the core logic (Key matrix creation, pair creation, pairwise encryption and decryption)
  • README.md explains the algorithm, how to use the code and sample input/output
  • playfairCipher.test.js includes tests for typical and edge cases

Testing: Run npm test — all tests should pass, including new ones.

Checklist:

  • [x] Code follows the style of existing algorithms in the repo
  • [x] Explanations/documentation added
  • [x] Tests added and passing
  • [x] No breaking changes

Dhvani365 avatar Oct 22 '25 09:10 Dhvani365

What's the point of submitting it here when we can all generate it the same way you did?

lazarljubenovic avatar Oct 22 '25 10:10 lazarljubenovic

What's the point of submitting it here when we can all generate it the same way you did?

Implementing code is different thing, but learning from this is an important thing. As part of my learning, I wanted to implement some of the standard algorithms in javascript (this is one of them). This PR if merged with javascript-algorithms repository shows my learning and contribution as well as motivates beginners to implement such standard algorithms in javascript and contribute!

Dhvani365 avatar Oct 23 '25 06:10 Dhvani365