Hi all
Exploiting crc with function
I am working on a algorithm, despite all attempts, I did not reach a result
Does anyone of the members correct me where I am wrong or amend the algorithm for me
I want to modify the code to calculate the value of the checksum
Checksum calculates the sum for a 2-byte checksum
These are some values to show how the function or algorithm is calculated
[/quote]
function CRC(Data: AnsiString): UInt16;
var
i,j,Sum,f : Integer;
begin
Sum := $0000;
for i := 1 to Length(Data) do
begin
Sum := Sum xor Ord(Data[i]);
for j := 1 to 8 do
begin
f := Sum and $0001 ;
Sum := Sum shr 1;
if f = 1 then Sum := Sum xor $FFFF ;
Sum:=sum;
end;
end;
Result := UInt16(Sum);
end;
Edit2.Text := IntToHex(CRC(Edit1.Text), 4);
Value :35E01A00 crc is 4A16
4ED8FFFFFFFF
4F4C00000000
8E8C00000001
CE8D00000002
0F4D00000003
4E8F00000004
8F4F00000005
CF4E00000006
0E8E00000007
4E8A00000008
8F4A00000009
CF4B0000000A
0E8B0000000B
4F490000000C
8E890000000D
CE880000000E
0F480000000
4E8000000010
8F4000000011
4A1635E01A00