Convert CRC - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Convert CRC

light...light... Posts: 1Member
Please Can anyone convert this code from php to java?


function bitbybit_crc32($str,$first_call=false){

//reflection in 32 bits of crc32 polynomial 0x04C11DB7

//=0xFFFFFFFF; //keep track of register value after each call
static $reg=0xFFFFFFFF;

//initialize register on first call
if($first_call) $reg=0xFFFFFFFF;

$zeros=$n<4 ? $n : 4;

//xor first $zeros=min(4,strlen($str)) bytes into the register

//now for the rest of the string

//put in enough zeros at the end

//xor the register with 0xFFFFFFFF
return ~$reg;

$str="123456789"; //whatever
$blocksize=4; //whatever


Sign In or Register to comment.