Hola David.
Aunque tarde, por que ya el trabajo está hecho, te pongo los códigos que usé para mis pruebas.
C++
Código PHP:
...
#define USHORT unsigned short
...
int crc16(const string &data, USHORT crc)
{
USHORT x(0);
int count = data.length();
while (--count >= 0)
{
USHORT z = (USHORT)(data[x++] << 8);
crc = (USHORT)(crc ^ z);
for(int i = 8; i > 0; --i)
crc = (crc & 0x8000) ? (USHORT)(crc << 1 ^ 0x1021) : (USHORT)(crc << 1);
}
return crc;
}
void main()
{
string data = "13|0000123|1|Maximilian|Mustermann|05051999|21092019";
cout << crc16(data, 3077) << endl;
Delphi:
Código Delphi
[-]
function Crc16(const data: string; crc: Word): Word;
var
x, z: Word;
count, i: Integer;
begin
count := Pred(data.Length);
x := 0;
while (count >= 0) do
begin
Dec(count);
Inc(x);
z := Word(data[x]) shl 8;
crc := crc xor z;
for i := 7 downto 0 do
if crc and $8000 <> 0 then
crc := (crc shl 1 xor $1021)
else
crc := (crc shl 1);
end;
Result := crc;
end;
...
var
data : string;
begin
data := '13|0000123|1|Maximilian|Mustermann|05051999|21092019';
ShowMessage(Crc16(data,3077).ToString);
end;
Saludos