For a simple overview and pseudocode on XTea, you can wiki-it.

XTea is supposed to be a simple encryption algorithm, and it is mathematically. But my implementation is going wrong somewhere in the encryption and possibly decryption phases. Very wrong. Like it could simply crash silently on me, or the encryption "halts" part way through. It seems to be something in relation to password length and content length. It might work with a 16 character password, and a short paragraph, but change either around and it'll go screwy in no time flat!

As you can guess it's got me fairly confused. ops: I have to thank Lifepower a lot just for helping me this far along! Any further help from ya'll will really be appreciated. I'll be trying to juggle the discussion here and at Afterwarp, so just know that unless you check the thread there, you might not be up to date on the problem.

Here's the source. To use it just make a TXTea object, create it, Init the key, Encrypt/Decrypt then burn it.

Code:
(******************************************************************************)
(*  Translated from C into Object Pascal by Robert Kosek with much help from  *)
(*  Yuriy Kotsarenko. Please leave this header in any subsequent distribution *)
(*  and maybe mention us in the credits of whatever uses this.  Especially    *)
(*  Yuriy, he did the majority of the work in the end. ;-)                    *)
(*                                                                            *)
(*  My only stipulation to this is that if you use it, adapt it or change it, *)
(*  please let us know and post your changes here:                            *)
(*    http://www.afterwarp.net/forum/thread460.html                           *)
(******************************************************************************)
(*  Original code taken from:                                                 *)
(*    http://en.wikipedia.org/wiki/XTEA                                       *)
(*    http://www.irnis.net/soft/xted/                                         *)
(*                                                                            *)
(*  Our Sites:                                                                *)
(*    http://afterwarp.net/                                                   *)
(*    http://thewickedflea.com/                                               *)
(******************************************************************************)
unit xtea;

interface

uses SysUtils;

type
  PKey128 = ^TKey128;
  TKey128 = array [0..3] of longword;
  
  PBlock64 = ^TBlock64;
  TBlock64 = array [0..1] of longword;

  TXTea = class(TObject)
  private
    FKey: TKey128;
    FInitialized: Boolean;
  public
    property Initialized: boolean read FInitialized default false;
    procedure Burn;
    procedure InitKey(const Key: string);
    function Encrypt(const Input: string): string;
    function Decrypt(const Input: string): string;
    destructor Destroy; override;
    constructor Create;
  end;

const
  DELTA = $9e3779b9;
  XTEA_BLANK: TBlock64 = (0,0);
  XTEA_BURN: TKey128 =(0,0,0,0);

implementation

destructor TXTea.Destroy;
begin
  Burn;
  inherited Destroy;
end;

constructor TXTea.Create;
begin
  inherited Create;
  Burn;
end;

procedure TXTea.Burn;
begin
  FKey := XTEA_BURN;
  FInitialized := False;
end;

procedure TXTea.InitKey(const Key: string);
var L: integer;
begin
  if Length&#40;Key&#41; <= SizeOf&#40;FKey&#41; then
    L &#58;= Length&#40;Key&#41;
  else
    L &#58;= SizeOf&#40;FKey&#41;;

  Move&#40;Key&#91;1&#93;,FKey&#91;0&#93;,L&#41;;
  
  FInitialized &#58;= True;
end;

function TXTea.Encrypt&#40;const Input&#58; string&#41;&#58; string;
var i,l,n,b&#58; integer;
    v&#58; TBlock64;

  procedure CipherXTea&#40;v&#58; PBlock64; key&#58; PKey128&#41;;
  var sum&#58; longword;
      i&#58; integer;
  begin
    Sum&#58;= 0;

    for i&#58;= 0 to 31 do
    begin
     Inc&#40;v&#91;0&#93;, &#40;&#40;v&#91;1&#93; shl 4 xor v&#91;1&#93; shr 5&#41; + v&#91;1&#93;&#41; xor &#40;Sum + Key&#91;Sum and 3&#93;&#41;&#41;;
     Inc&#40;Sum, Delta&#41;;
     Inc&#40;v&#91;1&#93;, &#40;&#40;v&#91;0&#93; shl 4 xor v&#91;0&#93; shr 5&#41; + v&#91;0&#93;&#41; xor &#40;Sum + Key&#91;Sum shr 11 and 3&#93;&#41;&#41;;
    end;
  end;
begin
  if not Initialized then
    raise Exception.Create&#40;'Error&#58; You must define a password.'&#41;;

  b &#58;= SizeOf&#40;v&#41;;
  l &#58;= Length&#40;Input&#41;;
  SetLength&#40;Result,l&#41;;

  i &#58;= 1;
  while i < l do
    try
      v &#58;= XTEA_BLANK;
      n &#58;= l - &#40;i-1&#41;;

      if n > b then
        Move&#40;Input&#91;i&#93;,v&#91;0&#93;,b&#41;
      else
        Move&#40;Input&#91;i&#93;,v&#91;0&#93;,n&#41;;

      CipherXTea&#40;@v,@FKey&#41;;

      Move&#40;v&#91;0&#93;,Result&#91;i&#93;,b&#41;;
      inc&#40;i,8&#41;;
     except
       raise;
     end;
end;

function TXTea.Decrypt&#40;const Input&#58; string&#41;&#58; string;
var i,l,n,b&#58; integer;
    v&#58; TBlock64;

  procedure DecipherXTea&#40;v&#58; PBlock64; Key&#58; PKey128&#41;;
  var
     i&#58; Integer;
     Sum&#58; Longword;
  begin
    Sum&#58;= $C6EF3720;

    for i&#58;= 0 to 31 do
    begin
      Dec&#40;v&#91;1&#93;, &#40;&#40;v&#91;0&#93; shl 4 xor v&#91;0&#93; shr 5&#41; + v&#91;0&#93;&#41; xor &#40;Sum + Key&#91;Sum shr 11 and 3&#93;&#41;&#41;;
      Dec&#40;Sum, Delta&#41;;
      Dec&#40;v&#91;0&#93;, &#40;&#40;v&#91;1&#93; shl 4 xor v&#91;1&#93; shr 5&#41; + v&#91;1&#93;&#41; xor &#40;Sum + Key&#91;Sum and 3&#93;&#41;&#41;;
    end;
  end;
begin
  if not Initialized then
    raise Exception.Create&#40;'Error&#58; You must define a password.'&#41;;

  b &#58;= SizeOf&#40;v&#41;;
  l &#58;= Length&#40;Input&#41;;
  SetLength&#40;Result,l&#41;;

  i &#58;= 1;
  while i < l do
    try
      v &#58;= XTEA_BLANK;
      n &#58;= l - &#40;i-1&#41;;

      if n > b then
        Move&#40;Input&#91;i&#93;,v&#91;0&#93;,b&#41;
      else
        Move&#40;Input&#91;i&#93;,v&#91;0&#93;,n&#41;;

      DecipherXTea&#40;@v,@FKey&#41;;

      Move&#40;v&#91;0&#93;,Result&#91;i&#93;,b&#41;;
      inc&#40;i,8&#41;;
    except
      raise;  
    end;
end;

end.