I'm by no means an expert on cryptography, nor the math involved.. ;-)
Have a look at this, at which point i defer to a more experienced monk to explain the concepts of cypher block chaining.
Get yourself a copy of Applied Cryptography, its a great book that explains how all this works: various protocols, attacks, algorithms et al. Once you've read it and know all about how to implement good security, go read Secrets and Lies....