Dynamic Key

‘Fit for purpose’ implies suitability for the task in hand. When it comes to making a message secret, a fit for purpose cipher will have the strength necessary to withstand the circumstances. If the task is to encipher the occasional message and all messages are reasonably short (just a few thousand letters) then the circumstances are not severe. There’s no need, I suggest, for AES, which would be like taking a sledgehammer to knock in a one-inch nail.

In such circumstances there is scope for using your own cipher for two reasons: there is a certain satisfaction from doing your own thing and by so doing you can be sure there are no ‘nasties’ in the cipher – backdoors and so on.

On the other hand the experts will probably say that it’s very foolish to rely on a cipher that is not tried and tested by the ’community’.

Where the balance lies in all this I don’t know. But I think that a combination of well-tried classical encryption methods is quite strong enough to resist the sort of person who might steal my computer and try to read my secret messages. Or who alternatively may break into my Dropbox.

So with that in mind, here is my system that I call ‘Dynamic Key’. It uses a 26-letter key to encipher by substitution. But after each encipherment the key is shuffled so that the next encipherment is made with a completely different key. Moreover, every shuffle is different, being determined by a combination of the plain letter and the previous key.

The shuffling is good enough that the key never repeats. The ciphertext letters have the appearance of being drawn at random. A plaintext letter may be enciphered to any of the 26 letters of the alphabet, and is done so with equal probability.

Although the shuffling process is deterministic, it depends on the starting key – and of course this is unknown to an attacker. It is also too long to be acquired by brute force. Further since the key changes after each encipherment in a way determined by the current key, the attacker cannot apply the deterministic algorithm.

The enciphering algorithm is brief, just 19 lines of javascript and has no need for a random number generator. The algorithm can be viewed by clicking here and also is briefly described below.

The program can be run in your browser to encipher or decipher by clicking here. It will look like this:

And just as a last comment, when a lengthy ciphertext is converted to zeros and ones, the resulting bit stream passes Maurer’s test for randomness.


Algorithm:

You choose an enciphering key comprising the 26 letters of the alphabet in some order, say:

ZEBRASDONTFLYMUCHGIJKPQVWX

To encipher a letter we take the one that stands before it in the key. So plain ‘T’ -> cipher ‘N’

Now I want to transpose the key in a secret way before making the next encipherment. To make the first transposition index I take two factors unknown to the enemy:
     the position of the plain letter in the current key =9
     the position of the plain letter in the alphabet = 19
and add them modulo 26 which gives me 2 and I pick the letter at this position in the key = B

To make the second transposition index I use the value 2 and add it to 19 (as before) mod 26 = 21, which in the key points to P

For the third index I add 21 to 19 mod 26 = 14, pointing to U in the key.

Carrying on in this way I get the new transposition index BPUOZJYRXG.

Finally I put the enciphering key into 10 columns and strip it in order given by the transposition key:

BPUOZJYRXG
ZEBRASDONT
FLYMUCHGIJ
KPQVWX

to give the new enciphering key ZFKTJSCXRMVELPOGBYQNIDHAUW


Now the second plain letter ‘H’ is enciphered to ‘D’, a new transposition key is made    TVYUSLNZXO

and from it a different shuffle gives a new enciphering key        SGWCBMNJOUZVITPAFEDRQKLHXY

Continuing in this way:

Plain: the best things in life are free
Cipher NDF FXIU EPOLKI WZ QJUM UEL MKXY