Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function crc16(s:string):Word;
- var i,j:byte;
- begin
- Result:=0;
- for i:=1 to Length(s)do
- begin
- Result := Result xor Ord(s[i]) shl 8;
- j := 8;
- while j<>0 do
- begin
- if (Result and $8000 = $8000) then //( BYTE1(v2) & 0x80 )
- Result := 2 * Result xor $8005
- else
- Result := Result * 2;
- Dec(j);
- end;
- end;
- end;
- ////////////////////////////////////
- ///////////////////////////////////
- //...
- tmp:=(len+lenID) div 2;
- p1:=format('%0.4x',[crc16(Copy(szName+szID,1, tmp))]);
- p2:=format('%0.4x',[crc16(Copy(szName+szID,tmp+1, len+lenID-tmp))]);
- serial:='HT-'+p1+'-'+p2;
- //...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement