Wednesday, 29 November 2017

The silent GPS


As a part of my work, I recently had to work on a GPS unit. This is about my misadventures trying to get it to work.
The trouble began with it being a rather old unit, and as such it wasn't exactly as simple as more modern units would have been. Still, I did figure out how it was supposed to work - so far, so good. I got the components, set everything up, and expected to get a reading.
Except I got no such thing.
My immediate first guess was a communication problem - I wasn't too familiar with it after all and the power light was on. So I looked it up, and checked the cable. Nope. It's working perfectly. I checked the settings against the manual. My settings were correct.
Then I went through the manual again to see whether any of my commands or settings were wrong. Nope.
The only other option was power. On closer inspection, the unit wasn't drawing any current. So, I had identified the problem.
The unit had a fuse. That was my first suspect. Tested it - no, it wasn't blown.
Then I checked the power circuit. It said 12 V, but the GPS itself was rated to handle a range of voltages, so to be on the safe side I had gone with 11.5 V. On closer inspection I saw a 7810 regulator. The rated input is 12.5 V, but even with a lower voltage it should have given a steady DC output, though probably at less than 10 V. The GPS should have worked under those circumstances. still, nothing had worked and I was a little short of resorting to an exorcism, so I thought I might as well increase the voltage to 12.5 V. Still, no response. It simply wasn't drawing any current.
At this point, I was reaching the concluded that something was possibly fried.
The next task was identifying what was fried. It was either the power supply or the GPS. Fortunately the designers of the unit had allowed for measuring the current output. That allowed me to determine that the output power from the supply was zero.
Having determined that, I checked the supply again. Possibly there was something I had missed, something that would allow me to identify the real problem. Perhaps a small switch on the board...
There was no such thing. Finally, I closed the box, and lo and behold, on the outside of it, was a rather large power switch. It was in the off position.
I turned it on, and well, it worked.
At least, thanks to this fiasco, I had read the manual thoroughly and all the connections were right when I finally switched it on. On the flip side, I wasted quite a few hours of my life.
So, the point I want to make is, always check the obvious, and do not blindly trust power buttons.


yours truly,
Falcon-15-X-C

Tuesday, 7 November 2017

The Vigenere Cipher

This article is meant for writers looking for inspiration, cipher enthusiasts, and anyone interested in this topic. Don't bother using this for nefarious purposes - a real cryptoanalyst will probably pick it apart in minutes.

This is a continuation from my previous article on ciphers on simple substitution ciphers. The Vigenere cipher is the next logical step from the simple substitution cipher. Before we start, let's get the terminology cleared up:

Plaintext: The text that is ciphered, in plain English (or whatever language you prefer).
Ciphertext: The ciphered text.
Key: the key to cracking the cipher, either a number or a word, or a random selection of letters. More on this later.

So, to get started, do you remember the Caesar cipher from the last article? It involves shifting the entire alphabet by a fixed amount to produce the cipher alphabet. The whole Caesar cipher table is given below, with shifts from 0 to 25 are given below. It will be useful for understanding the Vigenere cipher.


The Vigenere Cipher works by combining several Caesar Ciphers into one. This is best illustrated with an example. Consider the following plaintext:

TEXT:            It is not in the stars to hold our destiny but in ourselves.
PLAINTEXT:
ITZISZNOTZINZTHEZSTARSZTOZHOLDZOURZDESTINYZBUTZINZOURSELVES

Note that all spaces have been replaced with 'Z' as discussed in the previous article. the entire text has been turned into uppercase, as the cipher we will be using here is not case sensitive. Now, let's try applying a simple substitution to it, say, Caesar 5:

CIPHERTEXT_CAESAR5: NYENXESTYENSEYMJEXYFWXEYTEMTQIETZWEIJXYNSDEGZYENSETZWXJQAJX

Several weaknesses are immediately obvious - for example, there are way too many 'E's, which gives away that they are spaces, and it all goes downhill from there. If you want to make this stronger, you could potentially use several Caesar ciphers in combination. Let's pick a random keyword - say, APPLE. (Don't judge me. If English books can do it, so can I).

To use this as a key,we have to convert it to the numerical equivalent - 0-15-15-11-4. If you want to, you can remove duplicates before this step. I chose not to in this example.

So, what does this key mean? It means that we will be using five alternating Caesar ciphers throughout the text - the first character will be Caesar 0, the second Caesar 15, and so on, until we hit the sixth character which will be Caesar 0 again. Ciphering the same plaintext gives:

CIPHERTEXT_KEY_APPLE:
IIOTWZBDEDIBOELEOHEERHOESZWDWHZDJCDDTHEMNNOMYTOXYDOJGDILLTW

The formula, by the way, is [plaintext+key, mod 26], with the alphabet at A=0, B=1, etc. Some sample calculation:

I 8 8+0, mod 26 = 8 I
T19 → 19+15, mod 26 = 34, mod 26 = 8 → I
Z → 25 → 25+15, mod 26 = 40, mod 26 = 14 → O
I → 8 → 8+11, mod 26 = 19 → T
S → 18 → 18+4, mod 26 = 22 → W
Z → 25 → 25+0, mod 26 = 25 → Z
and so on.

As you can see, there are fewer obvious clues in here. The letter frequency count gives 8 'D's, 7 'E's, and 7 'O's, and 'H', 'I', 'T', and 'W' are present four times each. This doesn't tell us so much. [frequncy analysis from https://www.mtholyoke.edu/courses/quenell/s2003/ma139/js/count.html]

The most reliable way to attack this cipher, if you know the key length, is to isolate the different Caesar ciphers and to attack them separately. For this cipher, provided you knew that the key length was 5, you could isolate the 1st, 6th and so on, then the 2nd, 7th, and so on - you get the idea. Then you can attack these as individual simple substitution ciphers.


As you can see, the resulting ciphertexts are much smaller than the original ciphertext. This makes it much more difficult to crack them. If your keyword/key phrase is the same length as the plaintext, it really will be nearly impossible to crack.

The risk of course, is the possibility of the key being intercepted. There are different ways to get around this - use a book cipher, encode your key (often a short word) in a simple substitution cipher that is not a Caeser cipher, or have the person on the other end know the keyword for the day/week/ whatever.

Variants

You can also use some variations on the Vigenere cipher. One is to take the key to its logical conclusion as mentioned above, and use a key of the same length as the message you want to send. There is always the problem of that being intercepted.

Another possibility is to use a numerical key - say, the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, 21, 34, ...). True, it increased beyond the number of characters rather quickly, and is strictly increasing (which can show itself in the cipher text), but this can be overcome by grouping them by digits (11, 23, 5, 8, 13, 21, 3, 4, ...). You can also consider using irrational numbers, or an irrational number of sequence multiplied by a constant - the number of ways you can play about with this is infinite.

Enjoy!

Falcon-15-X-C

How to write a character who is smarter than you

We all have that one character (or few) who is significantly smarter than the writer. So, as a writer, how do you write such a character con...