# Using XOR

This refers back to articles upon Lorenz, as well as One Time Pads.

I've been playing with a spreadsheet, and have managed to use it to get a basic implementation of a Lorenz-type cipher. It is far from perfect. The key is not generated 'on the fly', instead a repeating key is used. This renders the strength, and the method of solving, to be the same as a Vigenère or Beaufort.

In addition, it doesn't deal with the message switching from 'letters' to 'numbers' gracefully.

In this implementation, the 'control codes' are in triangular brackets (not the best choice for a webpage!), so <X> is 00000 (i.e. 'not used'), and <LF> is 'Line feed'.

If I'd used a real programming language I could have handled all this much more neatly - I could do it in excel too, but this is another few hours work!

The spreadsheet does gracefully switch between the letters and numbers column in the cryptotext though.

Here are the results!

I took the message:

```This is a simple message encoded
using the Lorenz cipher using a small key```

(which is actually a lie - the key is not Lorenz). I applied the key: abcdef. The key repeated, abcdefabcdef etc.. rendering this Lorenz-alike!

Then for the first character, I used the spreadsheet to look up the Baudot code. For 'T' this is '10000' (16). I did the same for the key, yielding '00011' (3).

These two are XORed together, to give 10011 (19). Looking this up on the table provides 'W'.

`T: 10000`
`A: 00011`
`W: 10011`

For the next letter we'd encode 'H', '10100' (20) with 'B', '11001' (25). This yields '01101' (13), of 'F'

`H: 10100`
`B: 11001`
`F: 01101`

Repeating this for every character gives:

W F <CR> N S J I X F F <SPACE> J <LETT> K M <CR> S Z <LF> M J R <NUM> , 7 9 <LF> 7 ? <SPACE> <LF> 5 4 : <SPACE> <BELL> ( - 4 ? 6 , 7 <BELL> 0 - <X> 3 ) / <X> ( i ? <LF> 2 4 : <SPACE> <BELL> ( - 4 4 ' <CR> <LETT> G M <NUM> ' <LF> <LF> ,

This is all very scary and intimidating. Much less so if it is viewed as a string of numbers:

19 13 08 12 05 11 06 29 13 13 04 11 31 15 28 08 05 17 02 28 11 10 27 12 07 24 02 07 25 04 02 16 10 14 04 11 15 03 10 25 21 12 07 11 22 03 00 01 18 29 00 15 23 25 02 19 10 14 04 11 15 03 10 10 05 08 31 26 28 27 05 02 02 12

This is still pretty scary, but it's probably much easier to deal with. Indeed, it is what would actually have been transmitted (ignoring my 'cut down' key). The text I included above is what the unencoded ciphertext produces when fed directly into a teleprinter which then tries to interpret the junk coming in as regular Baudot Code (though the teleprinter would have actually followed the 'control codes' and done line feeds, bells etc. as instructed).