Binary Overdose

This is a list of javascript ‘snippets’ I saved while working on projects recently. There’s ES6/7 stuff in there and some older JS too. I’m not advocating anything here as the best solution to any particular problem, just some mostly terse implementations of some common problems that might help others out.

It’s running time is linear in the number of items and the difference between the maximum and minimum key values, so it is only suitable for direct use in situations where the variation in keys is not significantly greater than the number of items.

Based on the Fisher-Yates shuffle, the Knuth shuffle requires less overhead. FYS stimulates that you should remove a random item out of the original array and place it in a new array, and repeat while never fetching from the same location twice.

This idea poped into my head the other day so I thought I would bosh out a test.

Basically the idea was to take an input image (the private key) and some data. Encode the data into a copy of the image (the public key) by increasing or decreasing the value of each pixels color channel by the ASCII code of each character in the dataset.