1. Well, the theories as a whole are not easy to understand, but some of the important theorems are. Look at the Handbook of Applied Cryptography; it has a fair bit of what you need, though in a rather terse format. Here is another link to an online book on algebra: http://www.math.uiuc.edu/~r-ash/Algebra.html

2. XORing or adding them together doesnt make much of a difference. If you take a piece of text, Encrypt it with a completely random string of letters and you get an imposssible to break cipher. No matter how much computer pwer youve got and how much time youve got you will never break the code. Adding them Exclusive-Or ing them whatever it doesnt matter. the reason i have got the %26) + 65 is to ensure all of the cipher characters are letters that can be saved in a file. Thanks!

3. XORing or adding them together doesnt make much of a difference.
True, but fuxxing about with the range using % is an easy way to get an encryption that you can't reverse unless you're damn good with practical modular arithmetic.
the reason i have got the %26) + 65 is to ensure all of the cipher characters are letters that can be saved in a file
Ya, I kinda figured that. But it's all just characters anyway, so it doesn't matter if they're letters or not. In fact, if they're just letters and not the full range of char then you've got yourself a weaker encryption.

4. To add on to Narf's last point:

a) You are not actually doing anything, as anything stored in a 'char' can be written to and read from a file; it may not look pretty, but then, that is not the point.
b) You now have an algorithm that loses information (that is, more than one plaintext map to a given ciphertext, so there is no one-to-one correspondence between plaintext space and ciphertext space). This makes it more of a hash function.
c) You assume 65 is the magical number associated with the character 'a'. Better just use 'a'.

A one-time pad with a perfectly random key is the highest level of encryption. However, rand( ) is not cryptographically secure (in general) anyway (in fact, I have never heard of a cryptogrpahically secure implementation of <cstdlib>'s rand( ) ).

Performing addition mod 2 on all of the bits is the same as a XOR.

5. Originally Posted by Junior89
Ok can anyone figure out why my code isnt working?
One reason why you have problems is that the automatically generated key and the encrypted text are not 0-terminated.
Kurt