crc32.js

 crc32.js

var crcTable;

function crcTableCalc()
{
	if(crcTable) return;

	crcTable = new Array(256);
	for(var i=0;i<256;i++)
	{
		var c=i;
		for(var k=0;k<8;k++) c = (c&1) ? 0xEDB88320^(c>>1) : c>>1;
		crcTable[i] = c;
	}
}

function crc32(str)
{
	var c = 0xFFFFFFFF;
	var sL = str.length;

	crcTableCalc();
	for(var n=0;n<sL;n++) c = crcTable[(c^str.charCodeAt(n))&0xff]^(c>>8);
	return c^0xffffffff;
}
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s