2009-09-22, 22:57
Would it be possible to get a javascript function for AJAX purposes that can take the path/filename and convert it to the correct thumbnail (tbn) filename?
public string Hash(string input)
{
uint m_crc = 0xffffffff;
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
bytes = encoding.GetBytes(input.ToLower());
foreach (byte myByte in bytes)
{
m_crc ^= ((uint)(myByte) << 24);
for (int i = 0; i < 8; i++)
{
if ((System.Convert.ToUInt32(m_crc) & 0x80000000) == 0x80000000)
{
m_crc = (m_crc << 1) ^ 0x04C11DB7;
}
else
{
m_crc <<= 1;
}
}
}
return String.Format("{0:x8}", m_crc);
}
function findCRC( string ) {
var CRC = 0xffffffff;
for ( var j = 0; j < string.length; j++ ) {
var c = string.charCodeAt(j);
CRC ^= c << 24;
for (var i = 0; i < 8; i++) {
if ( CRC & 0x800000000 )
CRC = (CRC << 1) ^ 0x04C11DB7;
else
CRC <<=1;
}
}
return CRC.toString(16);
}
Number.prototype.unsign = function(bytes) {
return this >= 0 ? this : Math.pow(256, bytes || 4) + this;
};
function FindCRC(data) { // computes crc value
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;
}
}
}
return CRC.toString(16);
}
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);
}
Fiasco Wrote: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");
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);
}
forumReader Wrote:123456789 returns 376e6e7
should return:
0376e6e7
CRC.toString(16);
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;
var CRC_str = CRC.toString(16);
while (CRC_str.length < 8) {
CRC_str = '0' + CRC_str;
}
return CRC_str;
}