-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add Baconian Cipher #1416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Baconian Cipher #1416
Conversation
What makes a simple substitution cipher algorithmically interesting?
What makes a simple substitution cipher algorithmically interesting?
That should have been a question for this PR: TheAlgorithms/Python#5251
I saw the algorithm is already in the site in Python and though about adding the JS version :)
I think this one is useful because someone studying ciphers might want to see the implementation in JavaScript.
What makes a simple substitution cipher algorithmically interesting?
That should have been a question for this PR: TheAlgorithms/Python#5251
True, but I'm afraid we are not the maintainers of the Python repo and we have different standards. We do not strive for parity with the other "algorithm" repos. In the future, please don't (mis)take other repos or legacy code in this repo as a good example for what to include.
I saw the algorithm is already in the site in Python and though about adding the JS version :)
I think this one is useful because someone studying ciphers might want to see the implementation in JavaScript.
Well, I find a good implementation pretty trivial and uninteresting, since it's just a substitution cipher (which also makes it an uninteresting cipher). For encoding, you just need a table from alphabet characters to code words, let's call it encoded
. Then your encoding function is just plaintext => plaintext.replace(/[A-Z]/g, character => encoded[character])
. Decoding is analogeously boring (since code words have fixed length): First flip the code table (const decoded = {}; for (const k in encoded) decoded[encoded[k]] = k
, then chiffretext => chiffretext.replace(/[AB]{5}/, codeword => decoded[codeword])
is your decoding function.
Uh oh!
There was an error while loading. Please reload this page.
Open in Gitpod know more
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.