Quote Originally Posted by Robert Kosek
Thanks, and I was actually going to write it as Stream to Stream encryption and decryption, with String overloads of each. And I'll probably recover the code by the MPL license, rather than my own. I'm not very good with legalese.

So I'll upload a final unit shortly, after I rewrite the functions real quick.

So there is a way around Delphi's implementation of binary shifts? I hope so, since I'm certain that it's our culprit. Or I could write a C* DLL or use the compiled .OBJs created for all this...
Sure there is a way around Delphi's implementation of Shifts. Simply write your own methods to do it for you (fair bit of warning, I'm doing this from the cuff with no IDE, so I'll guarntee its wrong):

[pascal]function RotateBitsRight(Param, Amount:Byte): Byte; // Note you could also do this as a var param
asm
ror Param, Amount // Rotate right
mov Amount, result
end;

function RotateBitsRight(Param, Amount:Byte): Byte; // Note you could also do this as a var param
asm
rol Param, Amount // Rotate left
mov Amount, result
end;[/pascal]

Anyways my point is, do it in assembly. Good reference guides can be found all over, but I use:
http://courses.ece.uiuc.edu/ece390/b.../inst-ref.html
http://www.intel.com/design/pentium4.../index_new.htm
http://www.nondot.org/sabre/os/files...imization.html
http://www.website.masmforum.com/tut...ute/index.html

Pretty much in that order. Looking at my code above, I know its wrong but it gets the idea across. You really would have to look into BASM and samples on the b.p.n.basm group for proper answers.