The $crc identifier calculates the 32-bit checksum of a text, binary variable, or file. Hash is 32-bits, shown as 8 upper-case hexadecimal characters.
Synopsis
$crc(plaintext|&binaryvar|filename[,N])
Parameters
plaintext - Used with N = 0, just the string you want the CRC-32 checksum hash of
&binaryvar - A binary variable, used with N = 1, return the CRC-32 checksum of the content of the binary variable
filename - A filename, used with N = 2, return the CRC-32 checksum of the content of the file
N: Optional integer 0-2, where 0 indicates data is treated as plaintext, 1 indicates a &binary variable, 2 treats data as contents of a filename
If the N parameter isn't used, the default 2 is used (which is different than $sha1 which has default of N=0.) Also different than $sha1, invalid N outside 0-2 range are treated as default 2 instead of creating an error.
Properties
None
Example
Echo the $crc hash of plain text string abc to the active window:
//echo -a $crc(abc,0)
The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC"
Echo the CRC-32 hash of the first 1000 bytes of the mIRC program you're running to the active window:
//bread $qt($mircexe) 0 1000 &snip | echo -a $crc(&snip,1)
Echo the CRC-32 hash of the contents of the mIRC program you're running to the active window:
//echo -a $crc($mircexe,2)
or
//echo -a $crc($mircexe)
Returns 00000000 if filename does not exist:
//echo -a $crc(no_such_file.txt,2)
Suggested Uses:
* Quick way to compare if 2 files are identical. (First check should always be comparing file sizes.)
* Quick way to check if a file's contents have changed since stored CRC checksum was made.
* Verify downloaded file hasn't been corrupted, matches the sender's original.
<br />
Note that because the default is N=2, '''$crc(versions.txt)''' is the CRC-32 for the contents of versions.txt (or 00000000 if the file doesn't exist). This differs from $sha1(versions.txt) giving the hash of the plaintext inside the parenthesis because $sha1 has default of N=0.<br />
mIRC v7.x Unicode-encodes plaintext before providing to $crc, so v7.x and v6.x return different answers for //echo -a $crc($chr(233),0)<br />
If the text doesn't have Unicode code points above 255, to avoid having Unicode points 128-255 encoded to 2-byte pairs, the text must be fed to $crc as a binary variable:<br />
<pre>//bset -ta &string 1 chloé | echo -a $crc(&string,1)
Error Messages
None
$crc differs from $sha1 in that it returns no error messages.
For non-existent filenames, it returns 00000000 instead of halting script with an error.
For calculating hash of $null string it returns nothing instead of the checksum of the null-string
When given invalid N outside the 0-2 range, it uses default 2 instead of halting script with an error.
Compatibility
Added: mIRC v5.6
Added on: 03 Jun 1999
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
for $crc(filename)
Added: mIRC v6.1
Added on: 29 Aug 2003
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.
for N=0-2 parameter
See also
v · d · e mIRC identifier list
$
$$, $, $0, $1-, $!, $&, $*, $+, $++, $?
A
$abook, $abs, $acos, $active, $activecid, $activewid, $adate, $address, $addtok, $addtokcs, $agent, $agentname, $agentstat, $agentver, $alias, $and, $anick, $ansi2mirc, $aop, $appactive, $appstate, $asc, $asctime, $asin, $atan, $atan2, $auto, $avoice, $away, $awaymsg, $awaytime
|
B
$banlist, $banmask, $base, $beta, $bfind, $bindip, $bitoff, $biton, $bits, $bnick, $bvar, $bytes
C
$calc, $caller, $cancel, $cb, $cd, $ceil, $chan, $chanmodes, $channel, $chantypes, $chat, $chr, $cid, $clevel, $click, $cmdbox, $cmdline, $cnick, $color, $colour, $com, $comcall, $comchan, $comchar, $comerr, $compact, $compress, $comval, $cos, $cosh, $count, $countcs, $cr, $crc, $creq, $crlf, $ctime, $ctimer, $ctrlenter
|
D
$date, $day, $daylight, $dbuh, $dbuw, $dccignore, $dccport, $dde, $ddename, $debug, $decode, $decompress, $deltok, $devent, $dialog, $did, $didreg, $didtok, $didwm, $dir, $disk, $dlevel, $dll, $dllcall, $dname, $dns, $donotdisturb, $dqwindow, $duration
E
$ebeeps, $editbox, $email, $emailaddr, $encode, $envvar, $error, $eval, $evalnext, $event, $eventid, $eventparms, $exists, $exiting
|
F
$false, $feof, $ferr, $fgetc, $file, $filename, $filtered, $find, $finddir, $finddirn, $findfile, $findfilen, $findtok, $findtokcs, $fline, $flinen, $floor, $font, $fopen, $fread, $fromeditbox, $fserv, $fserve, $fulladdress, $fulldate, $fullname, $fullscreen
|
G
$get, $getdir, $getdot, $gettok, $gmt, $group
H
$halted, $hash, $height, $hfile, $hfind, $hget, $highlight, $hmac $hmatch, $hnick, $host, $hotline, $hotlinepos, $hotlink, $hotp, $hregex, $hypot
|
I
$iaddress, $ial, $ialchan, $ibl, $idle, $iel, $ifmatch, $ifmatch2, $ignore, $iif, $iil, $inellipse, $ini, $initopic, $inmidi, $inmode, $inmp3, $inpaste, $inpoly, $input, $inrect, $inroundrect, $insong, $insongpause, $instok, $int, $intersect, $inwave, $inwho, $ip, $iptype, $iql, $isadmin, $isalias, $isbit, $isdde, $isdir, $isfile, $isid, $islower, $istok, $istokcs, $isupper, $isutf
|
K
$keychar, $keyrpt, $keyval, $knick
L
$lactive, $lactivecid, $lactivewid, $left, $leftwin, $leftwincid, $leftwinwid, $len, $level, $lf, $line, $lines, $link, $lock, $locked, $lof, $log, $log10, $logdir, $logstamp, $logstampfmt, $longfn, $longip, $lower, $ltimer
|
M
$maddress, $mask, $matchkey, $matchtok, $matchtokcs, $maxlenl, $maxlenm, $maxlens, $md5, $me, $menu, $menubar, $menucontext, $menutype, $mid, $mididir, $mircdir, $mircexe, $mircini, $mkfn, $mklogfn, $mknickfn, $mnick, $mode, $modefirst, $modelast, $modespl, $mouse, $mousecx, $mousecy, $mousedx, $mousedy, $mousekey, $mouselb, $mousex, $mousey, $mousewin, $mp3, $mp3dir, $msfile, $msgstamp, $msgtags
|
N
$N, $naddress, $network, $newnick, $nhnick, $nick, $nickmode, $no, $nofile, $nopath, $nopnick, $noqt, $not, $notags, $notify, $null, $numeric, $numtok, $nvnick
O
$ok, $online, $onlineserver, $onlinetotal $onpoly, $opnick, $or, $ord, $os
|
P
$parmN, $parms, $parseline, $parsetype, $parseutf, $passivedcc, $pi, $pic, $play, $pnick, $portable, $portfree, $pos, $poscs, $prefix, $prop, $protect, $puttok
Q
$qt, $query
R
$r, $raddress, $rand, $rands, $rawbytes, $rawmsg, $read, $readini, $readn, $regbr, $regerrstr, $regex, $regml, $regmlex, $regsub, $regsubex, $remote, $remove, $removecs, $remtok, $remtokcs, $replace, $replacecs, $replacex, $replacexcs, $reptok, $reptokcs, $result, $rgb, $right, $rnick, $round
|
S
$samepath, $scid, $scon, $script, $scriptdir, $scriptline, $sdir, $send, $server, $serverip, $servertarget, $sfile, $sha1, $sha256, $sha384, $sha512, $shortfn, $show, $signal, $sin, $sinh, $site, $sline, $snick, $snicks, $snotify, $sock, $sockbr, $sockerr, $sockname, $sorttok, $sorttokcs, $sound, $speak, $sqrt, $sreq, $ssl, $sslcertsha1, $sslcertsha256, $sslcertvalid, $ssldll, $ssllibdll, $sslready, $sslversion, $starting, $status, $str, $strip, $stripped, $style, $submenu, $switchbar, $sysdir
|
T
$tan, $tanh, $target, $tempfn, $ticks, $time, $timeout, $timer, $timestamp, $timestampfmt, $timezone, $tip, $tips, $titlebar, $token, $toolbar, $topic, $totp, $treebar, $true, $trust
U
$ulevel, $ulist, $unsafe, $upper, $uptime, $url, $usermode, $utfdecode, $utfencode
V
$v1, $v2, $var, $vc, $vcmd, $vcmdstat, $vcmdver, $version, $vnick, $vol
|
W
$wavedir, $wid, $width, $wildsite, $wildtok, $wildtokcs, $window, $wrap
|
X
$xor
Y
$yes
|
Z
$zip
=
=$nick
|