Hrmmm, well, with the code change, this makes for an interesting new problem. However, I would suggest that you look more carefully at your key generation methods. I looked at the rand function on my TI-BASIC (yeah, I know they have nothing to do with each other, it's just an example) and played with it and found out there are STRONG correlations in the data output by a seeded generator. I'm going to write the program in C and see what kind of correlations there are with your key generation method. ALSO, you seed the generator and then only generate a single number from it, which means that I can pick all values for your key and easily codebook the input and output keys. I don't know what range rand() generates numbers in, but, i'm assuming it's going to be a 32-bit integer. So, I'll get to work on finding the outward keys in relation to the inward keys and see how it looks. What's cool about doing this is that you can see key distributions on a scatter plot. If all the points are fairly evenly spread and in mostly organic patterns, you've got a good generator. However, if there are large holes or tightly concentrated areas, the key generator needs work.

I'm gonna get to work on my crypto basics tutorial set soon I guess. They'll cover:

Substitution methods and strengths:
-Mono Alphabetic
-Poly Alphabetic
-Homophonic

Fractionation:
-Basics
-Fractionation considerations

Transposition:
-Columnar and variations of it (unkeyed, keyed, patterened)
-Grid

Other funky constructs:
-Latin squares

Computer crypto basics and crypto math:
-Basic bitwise logic
-S-boxes
-Shift registers
-Basic block-cipher concepts
--Block cipher modes:
---ECB
---CBC
---CFB
---OFB
---others...
-Asymmetric crypto

Advanced computer crypto:
-Analyzing keyspaces and key distributions
-Determining the "randomness" of a random number generator
-Constructing good key generators

Basic cryptanalysis:
-Patterns
-Statistical attacks
-Applying what you know
-Normal attacks

Actually, for educational purposes, I've got my latin squre cryptosystem up on my site. It's basically composed of a latin square system, a key generator, and a fractionator/mapper. It can be found on the coding section of my site: http://cypherpunk.8bit.co.uk/coding.html

I'm not trying to plug my site here :/ I'm really just not fond of pasting a ~1k line euphoria program in the thread.