function SomaHex(Valor1, Valor2: String): String; begin Result := Format('%x', [StrToInt(HexDisplayPrefix + Valor1) + StrToInt(HexDisplayPrefix + Valor2)]); end; function SubtrairHex(Valor1, Valor2: String): String; begin Result := Format('%x', [StrToInt(HexDisplayPrefix + Valor1) - StrToInt(HexDisplayPrefix + Valor2)]); end; function CheckSum(linha: String): String; var i: Integer; begin Result := '00'; i := 1; while i < length(linha) do begin Result := SomaHex(Result, linha[i]+linha[i+1]); Inc(i, 2); end; if Length(Result) > 2 then Result := SubtrairHex('100', Copy(Result, 2, 2)) else Result := SubtrairHex('100', Result); end; ShowMessage(CheckSum('6a696d6d796a616d65737061747269636b76616e686f6c6c6768616e736b756c6c'));