From WikiChip
$sha256 identifier - mIRC
< mirc‎ | identifiers

$sha256 calculates the sha256 hash of a text, binary variable, or file. Hash is 160-bits, shown as 40 lower-case hexadecimal characters.


Synopsis[edit]

$sha256(plaintext|&binaryvar|filename,[N])

Parameters[edit]

plaintext - Used with N = 0, just the string you want the sha256 hash of

&binaryvar - A binary variable, used with N = 1, return the sha256 hash of the content of the binvar

filename - A filename, used with N = 2, return the sha256 hash 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 0 is used (which is different than $crc which has default of N=2.)

Properties[edit]

None

Example[edit]

Echo the sha256 hash of plain text string abc to the active window:

//echo -a $sha256(abc)
or
//echo -a $sha256(abc,0)

The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC"

Echo the sha256 hash of the zero-length null string to the active window:

//echo -a $sha256($null)

Echo the sha256 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 $sha256(&snip,1)

Echo the sha256 hash of the contents of the mIRC program you're running to the active window:

//echo -a $sha256($mircexe,2)

Note that because the default is N=0, $sha256($mircexe) is the sha256 hash for the plaintext text string of the drive:\path\filename for the mIRC you're running, and not the hash of the filename contents. This differs from $crc($mircexe) giving the checksum of the filename contents because $crc has default of N=2.
mIRC v7.x Unicode-encodes bytes 128-255 to utf8 before providing to $sha256, if the text doesn't have code points above 255, you can avoid the utf8 encoding issue by using a binvar with the -a switch.

//bset -ta &string 1 chloé | echo -a $sha1(&string,1)

Error Messages[edit]

Note that $sha256 differs from $crc in that it generates error for non-existent files instead of returning hash of $null string. Also, hex string returned by $sha256 is lowercase while $crc returns uppercase hex.

* Error accessing file: $sha256

Either file does not exist, or file permissions don't allow the file to be read. i.e. $sha256(non-existent-file,2) or $sha256(c:\hiberfil.sys,2)

* Invalid parameters: $sha256

Either using a zero-length/non-existent binary variable or specifying an N where $int(%N) isn't 0-2.

Both above errors halt execution of the script

Compatibility[edit]

Added: mIRC v7.42
Added on: 17/07/2015
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.


See also[edit]

v · d · e mIRC identifier list

$ $, $!, $?, $*, $&, $++, $+

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 $banmask, $base, $bfind, $bindip, $bitoff, $biton, $bits, $bnick, $bvar, $bytes

C $calc, $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, $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, $duration, $dqwindow

E $ebeeps, $editbox, $email, $emailaddr, $encode, $envvar, $error, $eval, $evalnext, $event, $eventid, $exists, $exiting

F $false, $feof, $ferr, $fgetc, $file, $filename, $filtered, $find, $finddir, $finddirn, $findfile, $findfilen, $findtok, $findtokcs, $fline, $floor, $font, $fopen, $fread, $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, $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, $isalias, $isbit, $isdde, $isdir, $isfile, $isid, $islower, $istok, $isupper, $isutf

K $keychar, $keyrpt, $keyval

L $lactive, $lactivecid, $lactivewid, $left, $leftwin, $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, $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, $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, $rawbytes, $rawmsg, $read, $readini, $readn, $regbr, $regex, $regml, $regmlex, $regsub, $regsubex, $remote, $remove, $removecs, $remtok, $remtokcs, $replace, $replacecs, $replacex, $reptok, $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, $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, $vcmd, $vcmdstat, $vcmdver, $version, $vnick, $vol

W $wavedir, $wid, $width, $wildsite, $wildtok, $window, $wrap

X $xor

Y $yes

= =$nick