Background:
Quite a long time ago (somewhere 1998) I thought I was really clever and invented my own encryption/decryption code. Looking through old code I rediscovered my old algorithm. (No, it was never used in any production environment.)
I'm wondering what type of encryption my naive self invented back then. I'm guessing it is a polyalphabetic substitution cipher, but I'm not really sure?
My Questions:
- What type of algorithm is this?
- How weak is it against modern day cryptanalysis and what methods would be used to break it?
What the code below does:
The algorithm encrypts and decrypts based on a set 64 alphabets. Each alphabet consists of the same 64 characters in random order; each character is included exactly once per alphabet. This set of alphabets is effectively the key for the algorithm.
To start, the plaintext is base64 encoded. Then each individual character, in the base64 encoded plaintext, is substituted by a character from one of the alphabets. The first characters is (always) picked form the first alphabet, for subsequent characters the alphabet is selected based on the index-number of the substituted value of the character preceding it. So, it 'encrypts' one character at the time and, if one character in the ciphertext changes, the decryption will (most likely) be garbled from that point on.
The code also adds base64 style padding to the ciphertext, in an attempt to be 'even more secure' by passing of the ciphertext like regular base64 encoded data.
The Algorithm:
Encryption is being carried out over letters from a 64-element alphabet in the following mode:
$$C_0=F_0(P_0)\quad C_i=F_{C_{i-1}}(P_i)$$
Where $F:\mathbb Z_{64}\times \mathbb Z_{64}\to\mathbb Z_{64}$ represents 64 different, random, fixed permutations forming the key.