Mal ChatGPT gefragt:
Zitat von
Phoenix:
This code block is visual basic:
begin
crc := (crc >> 8) Xor crc16tab((crc Xor CByte(Asc(ch))) And &HFF);
end;
Please translate this to Delphi code.
Zitat von
ChatGPT:
Sure! Here is the equivalent Delphi code for the provided Visual Basic code block:
Code:
crc := (crc shr 8) xor crc16tab[(crc xor Byte(Ord(ch))) and $FF];
Assuming crc is a 16-bit unsigned integer variable, and crc16tab is an array of 256 16-bit unsigned integers.
Note that shr is the Delphi equivalent of the >> right-shift operator in Visual Basic. Byte(Ord(ch)) is used to convert the
ASCII character ch to a byte value, which is required by the crc16tab array. The $FF hexadecimal value is used to perform a bitwise AND operation with the byte value, ensuring that only the lower 8 bits are used in the computation.
Irgendwie cool. Und erschreckend. Ich habe ihm die Tabelle ja nicht mitgegeben, aber das Ding "rät" das es die Tabelle sein muss.