2009-09-23, 21:43
HOOORAY!!!!!
How to convert the path + filename to the CRC code for thumbnails in javascript.
Call from javascript:
var thumbcrc = FindCRC( "C:\Movie\Adventures Of Ford Fairlane.iso");
How to convert the path + filename to the CRC code for thumbnails in javascript.
Call from javascript:
var thumbcrc = FindCRC( "C:\Movie\Adventures Of Ford Fairlane.iso");
Code:
Number.prototype.unsign = function(bytes) {
return this >= 0 ? this : Math.pow(256, bytes || 4) + this;
};
function FindCRC(data) {
var CRC=0xffffffff;
data = data.toLowerCase();
for (var j=0; j<data.length; j++) {
var c = data.charCodeAt(j);
CRC ^= c << 24;
for(var i = 0; i<8; i++) {
if(CRC.unsign(8) & 0x80000000) {
CRC = (CRC << 1) ^ 0x04C11DB7;
} else{
CRC <<= 1;
}
}
}
if ( CRC < 0 ) CRC = CRC>>>0;
return CRC.toString(16);
}