Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some extra detail to readme

  • Loading branch information...
commit 5bbcc81ee1c0e09ce9313fd72f22d41fe887ebc6 1 parent e84cf5d
@rd13 authored
Showing with 7 additions and 42 deletions.
  1. +7 −42 README.md
View
49 README.md
@@ -1,58 +1,25 @@
-# TypeX Emulation
+# TypeX Emulator
-This is a Javascript implementation of the British Rotor Cipher Machine - [TypeX][2]. The Enigma has been used as a basis for this code as they have very similar workings, this version is a translation to Javascript from a [version written in C][1].
+This is a Javascript implementation of the British Rotor Cipher Machine - [TypeX][2].
-Improvements that I have made to the original code include:
-
-1. No longer relies on files for input / output.
-2. I have broken down the transformation into a better (more readable) format:
-
-The transformation steps are:
-
-* Input ->
-* Right Stator ->
-* Left Stator ->
-* Right Rotor ->
-* Middle Rotor ->
-* Left Rotor ->
-* Reflector ->
-* Left Rotor ->
-* Middle Rotor ->
-* Right Rotor ->
-* Left Stator ->
-* Right Stator ->
-* Output
-
-3. I wrote this with the intention of using it in a brute force attack. To do this we can iterate through all possible rotor settings / orientations. Please see brute_force.js for an example.
-
-4. Input validation is cleaner.
-
-5. Removed goto's, general housekeeping.
-
-6. Speed is almost double to that of the C implementation due to caching and no file read / writes (which helps when it comes to brute forcing).
-
-##### Example 1 - Encoding
+##### Example 1 - Enciphering
```javascript
var demo1 = TypeX.init('01234', '00100', 'AOAKN', 'This is the string to be encoded');
//demo1 == KLHESNYNIMQAZHIZROBHDZHKWRQFFRTY
```
-##### Example 2 - Decoding
+##### Example 2 - Deciphering
```javascript
var demo2 = TypeX.init('01234', '00100', 'AOAKN', 'KLHESNYNIMQAZHIZROBHDZHKWRQFFRTY');
//demo2 == THISXISXTHEXSTRINGXTOXBEXENCODED
```
-##### Brute Force
+##### Brute Force Decipher
The code in brute_force.js loops through every possible rotor position and orientation. It then inserts (in batches) the results into a Mongo collection.
To run this Javascript you will need Node with the [native Mongo module][3] installed.
-The brute force method assumes that we know the indicator key.
-
-The indicator key is 5 letters (A-Z), that indicate the starting position of each rotor.
-
```javascript
//Rotor orientations (5^2)
for (r1 = 0; r1 <= 1; r1++) {
@@ -77,11 +44,9 @@ if((/(\d)(?=.*\1)/).test(rotorPos)) continue;
var cipher_text = TypeX.init(rotorPos, rotorOri, 'AOAKN', 'KLHESNYNIMQAZHIZROBHDZHKWRQFFRTY');
```
-In the above example, there are 215,000 possible rotor settings, we can then harvest them into a database for further processing.
-
-We can then crawl this database and search for cribs, or we can perform a common bigram / trigram count which is probably an easier way to reduce this number.
+The brute force method assumes that we know the indicator key.
-See brute_force.js for an example of how to add an ngram count to your database.
+In the above example, there are 215,000 possible rotor settings, after inserting them into our Mongo collection we can then reduce them by searching for cribs or by ordering them by their common bigram / trigram count.
[1]: http://scholarworks.sjsu.edu/cgi/viewcontent.cgi?article=1244&context=etd_projects
[2]: http://en.wikipedia.org/wiki/Typex
Please sign in to comment.
Something went wrong with that request. Please try again.