CRC-32: Difference between revisions

Content deleted Content added
Line 74: Line 74:


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
There is no library function for this so we implement one. Icon/Unicon binary operations apply to large integers so we need to mask to the desired unsigned word size. This also only applies to full bytes.
<lang Icon>link hexcvt,printf
<lang Icon>link hexcvt,printf


Line 102: Line 103:
}
}
crc := ixor(0,mask) # quick implementation
crc := ixor(0,mask) # invert bits
every crc := iand(ixor(crcL[iand(255,ixor(crc,ord(!s)))+1],ishift(crc,-8)),mask)
every crc := iand(mask,
ixor(crcL[iand(255,ixor(crc,ord(!s)))+1],ishift(crc,-8)))
return hexstring(ixor(crc,mask))
return hexstring(ixor(crc,mask)) # return hexstring
end</lang>
end</lang>