Jump to content

Checksums


nago
 Share

Recommended Posts

I just need to compare a checksum of a file to a known, expected checksum of that file. Basically, I just want to alert the user if a certain file has been tampered with or not and checksum seems like the easiest way to go.

It doesn't need to be super-secure, so even CRC32 is good enough.

I did a little digging but it seems as though there isn't a CRC plugin for autoit? Only AutoIt code, which seems like it takes a long time. that's probably no good.

Can anyone recommend the easiest course of action here?

Link to comment
Share on other sites

Check this link out

http://www.autoitscript.com/forum/index.php?showtopic=58617&hl=md5
Does that require that I have to register that com object on my system? Ideally, because I want to distribute my code in a 'compiled' form, I need the most self-contained solution possible.

Anything else?

Link to comment
Share on other sites

Does that require that I have to register that com object on my system? Ideally, because I want to distribute my code in a 'compiled' form, I need the most self-contained solution possible.

Anything else?

Yes it does, but you can automate the registration using RunWait and @ComSpec. Nothing big.

Link to comment
Share on other sites

@all

Maybe this can get you going

#include-once

; CRC32 Encryption Function in AutoIt
; by the DtTvB

; Converted from Visual Basic code
; from http://www.di-mgt.com.au/src/basCRC32.txt

global $crcArray[256];
$crcArray[0] = 0x0;
$crcArray[1] = 0x77073096;
$crcArray[2] = 0xEE0E612C;
$crcArray[3] = 0x990951BA;
$crcArray[4] = 0x76DC419;
$crcArray[5] = 0x706AF48F;
$crcArray[6] = 0xE963A535;
$crcArray[7] = 0x9E6495A3;
$crcArray[8] = 0xEDB8832;
$crcArray[9] = 0x79DCB8A4;
$crcArray[10] = 0xE0D5E91E;
$crcArray[11] = 0x97D2D988;
$crcArray[12] = 0x9B64C2B;
$crcArray[13] = 0x7EB17CBD;
$crcArray[14] = 0xE7B82D07;
$crcArray[15] = 0x90BF1D91;
$crcArray[16] = 0x1DB71064;
$crcArray[17] = 0x6AB020F2;
$crcArray[18] = 0xF3B97148;
$crcArray[19] = 0x84BE41DE;
$crcArray[20] = 0x1ADAD47D;
$crcArray[21] = 0x6DDDE4EB;
$crcArray[22] = 0xF4D4B551;
$crcArray[23] = 0x83D385C7;
$crcArray[24] = 0x136C9856;
$crcArray[25] = 0x646BA8C0;
$crcArray[26] = 0xFD62F97A;
$crcArray[27] = 0x8A65C9EC;
$crcArray[28] = 0x14015C4F;
$crcArray[29] = 0x63066CD9;
$crcArray[30] = 0xFA0F3D63;
$crcArray[31] = 0x8D080DF5;
$crcArray[32] = 0x3B6E20C8;
$crcArray[33] = 0x4C69105E;
$crcArray[34] = 0xD56041E4;
$crcArray[35] = 0xA2677172;
$crcArray[36] = 0x3C03E4D1;
$crcArray[37] = 0x4B04D447;
$crcArray[38] = 0xD20D85FD;
$crcArray[39] = 0xA50AB56B;
$crcArray[40] = 0x35B5A8FA;
$crcArray[41] = 0x42B2986C;
$crcArray[42] = 0xDBBBC9D6;
$crcArray[43] = 0xACBCF940;
$crcArray[44] = 0x32D86CE3;
$crcArray[45] = 0x45DF5C75;
$crcArray[46] = 0xDCD60DCF;
$crcArray[47] = 0xABD13D59;
$crcArray[48] = 0x26D930AC;
$crcArray[49] = 0x51DE003A;
$crcArray[50] = 0xC8D75180;
$crcArray[51] = 0xBFD06116;
$crcArray[52] = 0x21B4F4B5;
$crcArray[53] = 0x56B3C423;
$crcArray[54] = 0xCFBA9599;
$crcArray[55] = 0xB8BDA50F;
$crcArray[56] = 0x2802B89E;
$crcArray[57] = 0x5F058808;
$crcArray[58] = 0xC60CD9B2;
$crcArray[59] = 0xB10BE924;
$crcArray[60] = 0x2F6F7C87;
$crcArray[61] = 0x58684C11;
$crcArray[62] = 0xC1611DAB;
$crcArray[63] = 0xB6662D3D;
$crcArray[64] = 0x76DC4190;
$crcArray[65] = 0x1DB7106;
$crcArray[66] = 0x98D220BC;
$crcArray[67] = 0xEFD5102A;
$crcArray[68] = 0x71B18589;
$crcArray[69] = 0x6B6B51F;
$crcArray[70] = 0x9FBFE4A5;
$crcArray[71] = 0xE8B8D433;
$crcArray[72] = 0x7807C9A2;
$crcArray[73] = 0xF00F934;
$crcArray[74] = 0x9609A88E;
$crcArray[75] = 0xE10E9818;
$crcArray[76] = 0x7F6A0DBB;
$crcArray[77] = 0x86D3D2D;
$crcArray[78] = 0x91646C97;
$crcArray[79] = 0xE6635C01;
$crcArray[80] = 0x6B6B51F4;
$crcArray[81] = 0x1C6C6162;
$crcArray[82] = 0x856530D8;
$crcArray[83] = 0xF262004E;
$crcArray[84] = 0x6C0695ED;
$crcArray[85] = 0x1B01A57B;
$crcArray[86] = 0x8208F4C1;
$crcArray[87] = 0xF50FC457;
$crcArray[88] = 0x65B0D9C6;
$crcArray[89] = 0x12B7E950;
$crcArray[90] = 0x8BBEB8EA;
$crcArray[91] = 0xFCB9887C;
$crcArray[92] = 0x62DD1DDF;
$crcArray[93] = 0x15DA2D49;
$crcArray[94] = 0x8CD37CF3;
$crcArray[95] = 0xFBD44C65;
$crcArray[96] = 0x4DB26158;
$crcArray[97] = 0x3AB551CE;
$crcArray[98] = 0xA3BC0074;
$crcArray[99] = 0xD4BB30E2;
$crcArray[100] = 0x4ADFA541;
$crcArray[101] = 0x3DD895D7;
$crcArray[102] = 0xA4D1C46D;
$crcArray[103] = 0xD3D6F4FB;
$crcArray[104] = 0x4369E96A;
$crcArray[105] = 0x346ED9FC;
$crcArray[106] = 0xAD678846;
$crcArray[107] = 0xDA60B8D0;
$crcArray[108] = 0x44042D73;
$crcArray[109] = 0x33031DE5;
$crcArray[110] = 0xAA0A4C5F;
$crcArray[111] = 0xDD0D7CC9;
$crcArray[112] = 0x5005713C;
$crcArray[113] = 0x270241AA;
$crcArray[114] = 0xBE0B1010;
$crcArray[115] = 0xC90C2086;
$crcArray[116] = 0x5768B525;
$crcArray[117] = 0x206F85B3;
$crcArray[118] = 0xB966D409;
$crcArray[119] = 0xCE61E49F;
$crcArray[120] = 0x5EDEF90E;
$crcArray[121] = 0x29D9C998;
$crcArray[122] = 0xB0D09822;
$crcArray[123] = 0xC7D7A8B4;
$crcArray[124] = 0x59B33D17;
$crcArray[125] = 0x2EB40D81;
$crcArray[126] = 0xB7BD5C3B;
$crcArray[127] = 0xC0BA6CAD;
$crcArray[128] = 0xEDB88320;
$crcArray[129] = 0x9ABFB3B6;
$crcArray[130] = 0x3B6E20C;
$crcArray[131] = 0x74B1D29A;
$crcArray[132] = 0xEAD54739;
$crcArray[133] = 0x9DD277AF;
$crcArray[134] = 0x4DB2615;
$crcArray[135] = 0x73DC1683;
$crcArray[136] = 0xE3630B12;
$crcArray[137] = 0x94643B84;
$crcArray[138] = 0xD6D6A3E;
$crcArray[139] = 0x7A6A5AA8;
$crcArray[140] = 0xE40ECF0B;
$crcArray[141] = 0x9309FF9D;
$crcArray[142] = 0xA00AE27;
$crcArray[143] = 0x7D079EB1;
$crcArray[144] = 0xF00F9344;
$crcArray[145] = 0x8708A3D2;
$crcArray[146] = 0x1E01F268;
$crcArray[147] = 0x6906C2FE;
$crcArray[148] = 0xF762575D;
$crcArray[149] = 0x806567CB;
$crcArray[150] = 0x196C3671;
$crcArray[151] = 0x6E6B06E7;
$crcArray[152] = 0xFED41B76;
$crcArray[153] = 0x89D32BE0;
$crcArray[154] = 0x10DA7A5A;
$crcArray[155] = 0x67DD4ACC;
$crcArray[156] = 0xF9B9DF6F;
$crcArray[157] = 0x8EBEEFF9;
$crcArray[158] = 0x17B7BE43;
$crcArray[159] = 0x60B08ED5;
$crcArray[160] = 0xD6D6A3E8;
$crcArray[161] = 0xA1D1937E;
$crcArray[162] = 0x38D8C2C4;
$crcArray[163] = 0x4FDFF252;
$crcArray[164] = 0xD1BB67F1;
$crcArray[165] = 0xA6BC5767;
$crcArray[166] = 0x3FB506DD;
$crcArray[167] = 0x48B2364B;
$crcArray[168] = 0xD80D2BDA;
$crcArray[169] = 0xAF0A1B4C;
$crcArray[170] = 0x36034AF6;
$crcArray[171] = 0x41047A60;
$crcArray[172] = 0xDF60EFC3;
$crcArray[173] = 0xA867DF55;
$crcArray[174] = 0x316E8EEF;
$crcArray[175] = 0x4669BE79;
$crcArray[176] = 0xCB61B38C;
$crcArray[177] = 0xBC66831A;
$crcArray[178] = 0x256FD2A0;
$crcArray[179] = 0x5268E236;
$crcArray[180] = 0xCC0C7795;
$crcArray[181] = 0xBB0B4703;
$crcArray[182] = 0x220216B9;
$crcArray[183] = 0x5505262F;
$crcArray[184] = 0xC5BA3BBE;
$crcArray[185] = 0xB2BD0B28;
$crcArray[186] = 0x2BB45A92;
$crcArray[187] = 0x5CB36A04;
$crcArray[188] = 0xC2D7FFA7;
$crcArray[189] = 0xB5D0CF31;
$crcArray[190] = 0x2CD99E8B;
$crcArray[191] = 0x5BDEAE1D;
$crcArray[192] = 0x9B64C2B0;
$crcArray[193] = 0xEC63F226;
$crcArray[194] = 0x756AA39C;
$crcArray[195] = 0x26D930A;
$crcArray[196] = 0x9C0906A9;
$crcArray[197] = 0xEB0E363F;
$crcArray[198] = 0x72076785;
$crcArray[199] = 0x5005713;
$crcArray[200] = 0x95BF4A82;
$crcArray[201] = 0xE2B87A14;
$crcArray[202] = 0x7BB12BAE;
$crcArray[203] = 0xCB61B38;
$crcArray[204] = 0x92D28E9B;
$crcArray[205] = 0xE5D5BE0D;
$crcArray[206] = 0x7CDCEFB7;
$crcArray[207] = 0xBDBDF21;
$crcArray[208] = 0x86D3D2D4;
$crcArray[209] = 0xF1D4E242;
$crcArray[210] = 0x68DDB3F8;
$crcArray[211] = 0x1FDA836E;
$crcArray[212] = 0x81BE16CD;
$crcArray[213] = 0xF6B9265B;
$crcArray[214] = 0x6FB077E1;
$crcArray[215] = 0x18B74777;
$crcArray[216] = 0x88085AE6;
$crcArray[217] = 0xFF0F6A70;
$crcArray[218] = 0x66063BCA;
$crcArray[219] = 0x11010B5C;
$crcArray[220] = 0x8F659EFF;
$crcArray[221] = 0xF862AE69;
$crcArray[222] = 0x616BFFD3;
$crcArray[223] = 0x166CCF45;
$crcArray[224] = 0xA00AE278;
$crcArray[225] = 0xD70DD2EE;
$crcArray[226] = 0x4E048354;
$crcArray[227] = 0x3903B3C2;
$crcArray[228] = 0xA7672661;
$crcArray[229] = 0xD06016F7;
$crcArray[230] = 0x4969474D;
$crcArray[231] = 0x3E6E77DB;
$crcArray[232] = 0xAED16A4A;
$crcArray[233] = 0xD9D65ADC;
$crcArray[234] = 0x40DF0B66;
$crcArray[235] = 0x37D83BF0;
$crcArray[236] = 0xA9BCAE53;
$crcArray[237] = 0xDEBB9EC5;
$crcArray[238] = 0x47B2CF7F;
$crcArray[239] = 0x30B5FFE9;
$crcArray[240] = 0xBDBDF21C;
$crcArray[241] = 0xCABAC28A;
$crcArray[242] = 0x53B39330;
$crcArray[243] = 0x24B4A3A6;
$crcArray[244] = 0xBAD03605;
$crcArray[245] = 0xCDD70693;
$crcArray[246] = 0x54DE5729;
$crcArray[247] = 0x23D967BF;
$crcArray[248] = 0xB3667A2E;
$crcArray[249] = 0xC4614AB8;
$crcArray[250] = 0x5D681B02;
$crcArray[251] = 0x2A6F2B94;
$crcArray[252] = 0xB40BBE37;
$crcArray[253] = 0xC30C8EA1;
$crcArray[254] = 0x5A05DF1B;
$crcArray[255] = 0x2D02EF8D;

func sr8($x);
    local $n;
    $n = floor(bitAnd($x, 0x7fffffff) / 256);
    if (not(bitAnd($x, 0x80000000) = 0)) then;
        $n = bitOr($n, 0x800000);
    endIf;
    return $n;
endFunc;

func _convCRC32($data);
    local $crc, $i, $t, $c, $a, $l;
    $crc = 0xffffffff;
    $l = stringLen($data);
    for $i = 1 to $l;
        $c = asc(stringMid($data, $i, 1));
        $t = bitXor(bitAnd($crc, 0xff), $c);
        $a = sr8($crc);
        $crc = bitXor($a, $crcArray[$t]);
    next;
    return bitXor($crc, 0xffffffff);
endFunc;

regards,

ptrex

Link to comment
Share on other sites

I had tried using JSThePatriot's plugin, but I couldn't get it working. I'm a dunce at AutoIt, still.

ptrex's solution works. It doesn't provide the CRC that I'm familiar with, but as its only for internal comparisons, it should be fine.

Thank you.

(I wonder if the AutoIt authors will ever implement crc or md5 directly into AutoIt...? That would be pretty lush.)

Link to comment
Share on other sites

I had tried using JSThePatriot's plugin, but I couldn't get it working. I'm a dunce at AutoIt, still.

ptrex's solution works. It doesn't provide the CRC that I'm familiar with, but as its only for internal comparisons, it should be fine.

Thank you.

(I wonder if the AutoIt authors will ever implement crc or md5 directly into AutoIt...? That would be pretty lush.)

FileGetChecksum() would be nice but I think we may be waiting a long time for it to be implemented. If they were ever to look at doing this then we would also want them to do InetGetChecksum() so the Devs are in a position where they can not get ahead of the game. We tend to put a lot of pressure on them but then again that's what they get paid the big bucks for, right?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

FileGetChecksum() would be nice but I think we may be waiting a long time for it to be implemented. If they were ever to look at doing this then we would also want them to do InetGetChecksum() so the Devs are in a position where they can not get ahead of the game. We tend to put a lot of pressure on them but then again that's what they get paid the big bucks for, right?

I'm certainly not waving a gun and making demands :)

I'm coming to AutoIt from using mIRCScript pretty extensively, and I'm still getting used to occurrances where AutoIt just doesn't have the same or equivalent function. It'd be nice to have a checksum function, but probably not ultra critical.

Besides... AutoIt is free, and that's a pretty attractive pricetag.

Link to comment
Share on other sites

Besides... AutoIt is free, and that's a pretty attractive pricetag.

That's the key. I agree with what you suggested since I could make good use of it but for years now we have put pressure on the devs. There was even a time when you asked for something, if it could possibly be included it was. That isn't the case any more because there are simply too many requests that would only benefit a few. And I'm as guilty as the rest for requesting features. Some that were incorporated and some that were not. It's just a wait and see game. You can certainly ask for it on the Features Request TRAC.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If you want an MD5 hash that can be compared with others generated elsewhere, then you can use SkinnyWhiteGuy's MD5() for one entirely in AutoIt.

Keep in mind that hash functions are full of short logical operations and shifts repeated many, many times. That makes running them in an interpreted scripting language (AutoIt), very slow compared to a compiled C++ program.

I believe JSThePatriot moved those parts out to a DLL for just that reason in his MD5 Hash Plug-in.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Awesome link, Siao. That was very easy to mold into a crcfile() function for use!

...Here's hoping that it actually works on many computers. Can anyone understand the gobbledy-gook enough to comment on how resilient that code is? Should it work on most XP/2003/Vista PCs? Intel/AMD etc? Hmmm?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...