16,749
社区成员
发帖
与我相关
我的任务
分享
uses
winsock2;
procedure encipher(v: PUINT; const k: PUINT; w: PUINT);
var
y, Z, a, b, c,d, n, Sum, delta: UINT;
v1, k1: array of UINT;
begin
SetLength(v1, 2);
SetLength(k1, 4);
Move(v^, v1[0], SizeOf(UINT) * 2);
Move(k^, k1[0], SizeOf(UINT) * 4);
y := ntohl(v1[0]);
z := ntohl(v1[1]);
a := ntohl(k1[0]);
b := ntohl(k1[1]);
c := ntohl(k1[2]);
d := ntohl(k1[3]);
n := $10; //* do encrypt 16 (0x10) times */
sum := 0;
delta := $9E3779B9; //* 0x9E3779B9 - 0x100000000 = -0x61C88647 */
while (n > 0) do
begin
Dec(n);
sum := sum + delta;
y := y + ((z shl 4) + a) xor (z + sum) xor ((z shr 5) + b);
z := z + ((y shl 4) + c) xor (y + sum) xor ((y shr 5) + d);
w^ := htonl(y);
inc(w);
w^ := htonl(z);
end;
end;