Khan/khan-exercises — pull request #45621 by NickKolesar (2013-05-07 20:27:04+00:00)
Title: Trello card #520: New exercises - Caesar Cipher Frequency Analysis

Based on Trello card 520: this pull includes files that add a series of tools to build Caesar and Vigenere Cipher exercises. There are also four different example exercises which I will describe in the next post once the sandcastle links are created.

I did this work because:
1. I wanted to contribute to Khan Academy exercises
2. Become familiar with utility libraries like graphie, interactive, and word-problem
3. Because it was fun!

Cipher tools:
getCipherMessage(num): Call with a random or static number to return messages intended to be encrypted.

applyCaesar / applyVigenere (msg, key): Applies the specific encryption to a given message using a given shift or key word. Returns the encrypted message.

normEnglishLetterFreq (scale): Returns a normalized array containing the typical letter frequency of the English language. The scale parameter multiplies the entire array so you can scale it for specific graphs or images as necessary.

normCipherLetterFreq (cipher, scale): Returns a normalized array containing the letter frequency of a given cipher message. Scale parameter included again in case the values need to be tweaked for graph or image purposes.

The example exercises also include templates for:
Letter Frequency Bar chart: Creates a bar chart that compares the English language frequency to the letter frequency of an encrypted message.

![letterfreqbarchat](https://f.cloud.github.com/assets/1161011/473623/4fbf0c2e-b752-11e2-9397-bbf9ec873fb0.png)

Interactive Cipher Shift Tool: Uses javascript, css, and the interactive.js utility to create an interactive cipher alphabet key.
Note: Works in latest Chrome and Firefox browsers, but still needs a CSS exception/tweak to format correctly in the latest IE browser.

![interactiveciphertranslator](https://f.cloud.github.com/assets/1161011/473646/7009cf4a-b753-11e2-950f-21132674fcf0.png)