I've been following this thread with interest. I have a suggestion. If this algorithm will work fine on stream data then why not just make is encrpt and decrypt streams only? The Turbo Power LockBox functions do this, they mainly work on streams and have a wrapper function to convert the string to a memory stream (using TStreamStream and a copy) to handle the actual encryption.

I have found in the past with compression that dealing with strings directly can always be a bit tricky.

That is an interesting point about the C >> operator, I have had problems converting code which uses >> before but I can never remember how I get round it each time