![]() ![]()
If you look at the Wikipedia article linked above, you'll see there are different rules for how to encypt the output based on how the input letters are arranged in the grid. Playfair cipher program code code#More things I would like to add to this code as I develop it would be more rules on how to handle characters in the same row or columm. ![]() I suppose I could simply use a larger grid to support punctuation and special characters, though my inital thought was to perform a function on the output that loops through the input string and grabs the special characters then inserts them at the same index in the output string, however, using the larger grid would have the added functionality of using the special characters in the encryption, maybe making it more robust? I guess I'll just have to tinker with that and see what I find out. I would like to work on making the output format reflect the input format next, so punctuation etc. Note that the output string contains no spaces, punctuation, or special characters, and is all lowercase. The encryption and decryption use the same process, so as long as you have the correct passkey, the code works both ways. To decrypt the secret message, just run it back through the code. The code will output your encrypted message. To use it, change the input variable to the message you wish to encode, and the passkey variable to your secret password. I hope to one day build an HTML page to act as an interface for this script, but for now it just runs on its own. Playfair cipher program code plus#I have chosen to use a 6圆 grid (this concept is not my invention, by any means), offering space for 36 characters, which happens to perfectly fit all 26 letters, plus the 10 numerical digits 0-9. This also limits the messages you can send, as it does not support numbers. The reader then must decide which is the correct letter based on context. Often people combine either `I` and `J` or `Y` and `Z`. This forces a chosen pair of characters to share a space, as there is one less spot than there are letters of the alphabet. Traditionally, a Playfair Cipher utilizes a 5x5 grid to perform the encryption. I always wanted to build an auotmated one, so now that I am learning JavaScript, I have!Įxplanation on how a Playfair Cipher works can be found here: Playfair cipher program code movie#Inspired by the movie 'National Treasure', I have been having fun with Playfair Ciphers since about middle school. My code is below, and I will also link to the readme on GitHub: quinton-c/playfaircipher/blob/main/README.md # playfaircipher I wanted to focus on figuring out the actual loop logic and array structures, and not spend too much time on string manipulation, but I am going to spend some time researching all of the “ingredients” of that function so that I can still learn from it. I was very pleased to not have to cheat and look up how to accomplish any of the core logic, but I will admit I found the removeDuplicateCharacters function on Stack Overflow. ![]() This is the first project I’ve come up with and made myself outside of any lessons. Are there any ways this code could be refined to be simpler or more efficient? Any concepts I’ve not yet learned that could make this more powerful etc? Am I exhibiting any bad habits in this code that I need to stop? I was thinking this project may take me all day, and possibly even some on the weekend, but I was very happy to have it working in about 2.5 hours this morning! It’s still essentially the very first version of this (I have made a few tweaks throughout the afternoon, so I’ve labeled it version 0.1.1).Īs laid out in the readme, I still have some things I would like to add to this script to develop it, but I would love to hear from the community about this first version as well. Those unfamiliar with the Playfair Cipher can find more information on that here: Playfair cipher - Wikipedia It wound up not using objects, but was definitely some good practice for the other two. After learning about objects, arrays, and loops this week on the Full-Stack Engineer Career Path, I decided to practice what I had learned so far. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |