sub crc16 { my ($string, $poly) = @_; my $crc = 0; for my $c ( unpack 'C*', $string ) { $crc ^= $c; for ( 0 .. 7 ) { my $carry = $crc & 1; $crc >>= 1; $crc ^= $poly if $carry; } } return $crc; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter