mrandrewmills / substitution-cipher Goto Github PK
View Code? Open in Web Editor NEWJavaScript object for playing with simple monoalphabetic substitution ciphers.
JavaScript object for playing with simple monoalphabetic substitution ciphers.
Currently, you have to invoke buildKeyword() and then buildCipherAlphabet() before you can start encrypting or decrypting. I'm wondering if it wouldn't be better/easier to have buildKeyword() automatically trigger buildCipherAlphabet() automatically.
Thoughts?
Currently, any non-alphabetical character gets converted into a space by the encrypt() and decrypt() methods. So, apostrophes, quotes, hyphens, periods, all of that, gets turned into a space character.
How do real-life substitution ciphers handle such things? Need to do more research.
Since distillUniqueUpperAlphas is intended to be an internal/private utility function, shouldn't it be renamed to _distillUniqueUpperAlphas?
The buildKeyword() and buildCipherAlphabet() methods share a decent amount of repeated code. This should be put into a separate function to adhere to DRY principle.
There's a regex formula in the distillUpperUniqueAlphas that JSLint is complaining about as being potentially insecure.
phrase = phrase.replace(/[^a-zA-Z]/g, "");
If we can find another way to filter out non-alpha characters that JSLint won't complain about, I'd prefer it. If we can't, then we can't.
Just a note to remind myself to create and add JSDoc output later, as time permits.
I propose adding two new methods to this class.
The first method would be removeSpaces(). It would filter out any spaces between words, and make it harder for cryptanalysis to identify one or two letter words, which would increase the difficulty of the ciphertext.
The second method would be addSpace(number). It would iterate through the ciphertext characters and add a space at the interval specified in the method argument. So, addSpace(5) would add a space every fifth character, addSpace(1) would add a space between every character.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.