this slowpoke moves

CRC24 String Calculating

function CRC24(s: string): cardinal;
const
  crcInit = $000B704CE;
  crcPoly = $001864CFB;
var
  i,k: integer;
begin
  Result:= crcInit;
  for k:=1 to length(s) do
  begin
    Result := Result xor (ord(s[k]) shl 16);
    for i:=0 to 7 do
    begin
      Result:= Result shl 1;
      if (Result and $1000000) <> 0 then
        Result:= Result xor crcPoly;
    end;
  end;
  Result:= Result and $FFFFFF;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
var s : string; i : integer; 
begin
  s := Edit1.Text;
  i := CRC24(s);
  Label1.Caption := IntToStr(i);
  Label2.Caption := IntToHex(i,4);
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate