这个可以吗?
function Encrypt(Str,Key:String):String;
var
X, Y : Integer;
A : Byte;
begin
if Key = '' then
Key := 'd1duOsy3n6qrPr2eF9u';
Y := 1;
for X := 1 to length(Str) do
begin
A := (ord(Str[X]) and $0f) xor (ord(Key[Y]) and $0f);
Str[X] := char((ord(Str[X]) and $f0) + A);
inc(Y);
if Y > length(Key) then
Y := 1;
end;
Result := Str;
end;