BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
902aa40
Branches
Tags
master
mips_sys
stuff
crc32.pl
replace email address in headers with blinkenarea address
Stefan Schuermans
commited
902aa40
at 2012-05-21 17:42:50
crc32.pl
Blame
History
Raw
#! /usr/bin/perl # MIPS I system # Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org> # Copyleft GNU public license V2 or later # http://www.gnu.org/copyleft/gpl.html use strict; use warnings; # calculate CRC32 sub crc32 { my $bytes = shift; # array reference my @tab = ( 0x77073096, 0xEE0E612C, 0x076DC419, 0x0EDB8832, 0x1DB71064, 0x3B6E20C8, 0x76DC4190, 0xEDB88320 ); my $crc = 0xFFFFFFFF; for (my $i = 0; $i < @{$bytes}; ++$i) { my $val = $crc ^ @{$bytes}[$i]; $crc >>= 8; for (my $b = 0; $b < 8; ++$b) { if ($val & 1 << $b) { $crc ^= $tab[$b]; } } } $crc ^= 0xFFFFFFFF; $crc = [ $crc & 0xFF, $crc >> 8 & 0xFF, $crc >> 16 & 0xFF, $crc >> 24 & 0xFF ]; return $crc; # array reference } 1;