![]() ![]() ![]() Again, as a user I'd much rather be able to take input from a file and/or write output to a file (and this still allows me to run it interactively in the rare circumstance that I really want to).įor implementation of the cipher, I'd consider using a little math instead of the tables you're currently using. Likewise, each would act as a filter, taking its input from cin, and writing its output to cout (or possibly read/write other files if you specify them on the command line). The modification is done through the alteration of cell elements, where the ASCII decimal code equivalent of the key is the basis for the element positioning. As a user, I'd much rather type decrypt or encrypt than have to interactively enter an 'e' or 'd' to tell it whether to encrypt or decrypt. This paper modifies the traditional Polybius square with a 5x5 grid through the introduction of a new dynamic substitution-based matrix for ciphertext assignment. I think I'd start by splitting it into two pieces, one to encrypt and one to decrypt. If you expect every character to be upper case, either (1) tell the user (not recommended) or (2) upper case the string yourself: std::transform(input.begin(), input.end(), input.begin(), ::toupper) For example, for(int i = 0 i for std::isspace. Use ranged-based loop instead of index loop. Use auto to simply some variable definitions if you want to: // std::vector coords = getCoords() Don't allocate memory if you don't have too (this might actually not allocate memory for the std::string, due to SSO actually). SquareIJ doesn't have to be a std::string, it can be a simple char. Your choice variable really wants to be an enum instance: enum class mode When compiled with -Wall, your code produces 2 same warnings: warning: comparison between signed and unsigned integer expressions You can use different grid such as 6圆, 7x7 and more but the commonly. How to use Polybius square We can use polybius square by simply creating a 5x5 grid that has a set of numbers and letters. It's not that messy IMO, but there are a few things which you could have done better:Īlways compile code with every warning turned on, and fix them. Polybius square is also known as the Polybius Checkerboard is one of the cryptography invented by Polybious, an Ancient Greek historian and scholar. This code, in my opinion, is quite messy. ![]() The getCoords() function gets a string, and then tokenizes the string into a vector of strings, each corresponding to the coordinates of a character.Įxample of "encryption": Encrypt or decrypt = eĮxample of "decryption": Encrypt or decrypt = dĬoordinates (separate with spaces): 12 11 44 The getChoice() function simply gets the e or d character to choose encryption or decryption. As shown in the unordered map and char array, the numbers correspond to the row and column on a 5x5 square: The Polybius square is a simple way to assign characters numbers, and then "encrypt" and "decrypt" based off of those numbers. Since it is an uncommon cipher, it is nowhere on Code Review.Īlthough the program technically works, it ended up very messy. txt file is free by clicking on the export iconĬite as source (bibliography): ADFGVX Cipher on dCode.I attempted to recreate the Polybius square, also called the Polybius checkerboard, which was used in Ancient Greece for cryptography. The copy-paste of the page "ADFGVX Cipher" or any of its results, is allowed (even for commercial purposes) as long as you cite dCode!Įxporting results as a. Except explicit open source licence (indicated Creative Commons / free), the "ADFGVX Cipher" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "ADFGVX Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "ADFGVX Cipher" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app! Ask a new question Source codeĭCode retains ownership of the "ADFGVX Cipher" source code. The theorem of Roitelet is a novel by Frédéric Cathala here (link) which has as protagonist a spy during the first world war having messages encrypted with ADFGVX. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |