CryptoCon.pas will not work with byte arrays larger than the buffer (4096 bytes). NB this is noted by Greg Carter in the original source!.

First allow the TCrypto class to accept with byte arrays larger than 65535 bytes.

Change FInputLength from a WORD to a Integer.
And change the property to reflect this


   property InputLength : integer read FInputLength write FInputLength;

Again changing the WORD to a integer.



Next upgrade the EncipherData procedure's case statment.
The original source looks like this


    SourceByteArray:
    begin
     {Check Length!!!!}
     Move(FInputArray^, FBuffer, FInputLength);
     Encipher_Bytes;
    end;


Change it to


    //Modified by Andre v.d. Merwe 
    SourceByteArray:
    begin
       iPosition := 0;
       iInLen := InputLength;
       iOutLen := 0;
       iLen := iInLen - iPosition;

       szIn := PChar(FInputArray);
       szOut := PChar(FOutputArray);

       while(  iLen > 0  ) do
       begin
          if(  iLen > 4088  ) then
             iRead := 4088
          else
             iRead := iLen;

          Move(  szIn[ iPosition ],  FBuffer,  iRead  );
          InputLength := iRead;
          FInputArray := @FBuffer;
          FOutputArray := @FBuffer;

          Encipher_Bytes;

          Move(  FBuffer,  szOut[ iPosition ],  InputLength  );

          iPosition := iPosition + iRead;
          iLen := iInLen - iPosition;
          iOutLen := iOutLen + InputLength;
       end;

       InputLength := iOutLen;

     (*  -Original Code - Start

     {Check Length!!!!}
     Move(FInputArray^, FBuffer, FInputLength);
     Encipher_Bytes;

     -Original Code - End*)
    end;

Next add the following variables to the Encipher data procedure


   szIn,  szOut : PChar;
   iLen,  iRead,  iPosition,  iInLen,  iOutLen : integer;



Then change the corresponding section in the DecipherData procedure

From


    SourceByteArray:
    begin
        {Check Length!!!!}
        Move(FInputArray^, FBuffer, FInputLength);
        Decipher_Bytes;
    end;


to


    //Modified by Andre v.d. Merwe 
    SourceByteArray:
    begin
       iPosition := 0;
       iInLen := InputLength;
       iOutLen := 0;
       iLen := iInLen - iPosition;

       szIn := PChar(FInputArray);
       szOut := PChar(FOutputArray);

       while(  iLen > 0  ) do
       begin
          if(  iLen > 4088  ) then
             iRead := 4088
          else
             iRead := iLen;

          Move(  szIn[ iPosition ],  FBuffer,  iRead  );

          InputLength := iRead;
          FInputArray := @FBuffer;
          FOutputArray := @FBuffer;

          Decipher_Bytes;

          Move(  FBuffer,  szOut[ iPosition ],  InputLength  );

          iPosition := iPosition + iRead;
          iLen := iInLen - iPosition;
          iOutLen := iOutLen + InputLength;
       end;

       InputLength := iOutLen;

     (*  -Original Code - Start

        {Check Length!!!!}
        Move(FInputArray^, FBuffer, FInputLength);
        Decipher_Bytes;

     -Original Code - End*)
    end;

Finally add the following variables to the DecipherData procedure


   szIn,  szOut : PChar;
   iLen,  iRead,  iPosition,  iInLen,  iOutLen : integer;