(→Parameters) |
m (Fix number of characters shown.) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {{mirc title|$sha512 identifier}}'''$sha512''' calculates the [[sha512 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as | + | {{mirc title|$sha512 identifier}}'''$sha512''' calculates the [[sha512 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 128 lower-case hexadecimal characters. |
+ | |||
== Synopsis == | == Synopsis == | ||
Line 19: | Line 20: | ||
== Example == | == Example == | ||
− | Echo the | + | Echo the SHA512 hash of plain text string ''abc'' to the active window: |
− | <pre>//echo -a $ | + | <pre>//echo -a $sha512(abc) |
or | or | ||
− | //echo -a $ | + | //echo -a $sha512(abc,0)</pre> |
The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC" | The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC" | ||
− | Echo the | + | Echo the SHA512 hash of the zero-length null string to the active window: |
− | <pre>//echo -a $ | + | <pre>//echo -a $sha512($null)</pre> |
− | |||
− | |||
− | |||
− | Echo the | + | Echo the SHA512 hash of the first 1000 bytes of the mIRC program you're running to the active window: |
− | <pre>//echo -a $ | + | <pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha512(&snip,1)</pre> |
− | + | Echo the SHA512 hash of the contents of the mIRC program you're running to the active window: | |
− | + | <pre>//echo -a $sha512($mircexe,2)</pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Note that because the default is N=0, '''$sha512($mircexe)''' is the SHA512 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.<br /> | |
+ | mIRC v7.x Unicode-encodes bytes 128-255 to utf8 before providing to $sha512, 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. | ||
<pre>//bset -ta &string 1 chloé | echo -a $sha1(&string,1)</pre> | <pre>//bset -ta &string 1 chloé | echo -a $sha1(&string,1)</pre> | ||
== Error Messages == | == Error Messages == | ||
− | Note that $ | + | Note that $sha512 differs from $crc in that it generates error for non-existent files instead of returning hash of $null string. Also, hex string returned by $sha512 is lowercase while $crc returns uppercase hex. |
− | <pre>* Error accessing file: $ | + | <pre>* Error accessing file: $sha512</pre> |
− | Either file does not exist, or file permissions don't allow the file to be read. i.e. $ | + | Either file does not exist, or file permissions don't allow the file to be read. i.e. $sha512(non-existent-file,2) or $sha512(c:\hiberfil.sys,2) |
− | <pre>* Invalid parameters: $ | + | <pre>* Invalid parameters: $sha512</pre> |
Either using a zero-length/non-existent binary variable or specifying an N where $int(%N) isn't 0-2. | Either using a zero-length/non-existent binary variable or specifying an N where $int(%N) isn't 0-2. | ||
Line 58: | Line 52: | ||
== Compatibility == | == Compatibility == | ||
− | {{mIRC compatibility| | + | {{mIRC compatibility|7.42}} |
== See also == | == See also == | ||
Line 65: | Line 59: | ||
* {{mIRC|$sha256}} | * {{mIRC|$sha256}} | ||
* {{mIRC|$sha384}} | * {{mIRC|$sha384}} | ||
− | * {{mIRC|$ | + | * {{mIRC|$sha1}} |
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
− | [[Category:mIRC identifiers| | + | [[Category:mIRC identifiers|sha512]] |
Latest revision as of 17:49, 19 July 2024
$sha512 calculates the sha512 hash of a text, binary variable, or file. Hash is 160-bits, shown as 128 lower-case hexadecimal characters.
Synopsis[edit]
$sha512(plaintext|&binaryvar|filename,[N])
Parameters[edit]
plaintext - Used with N = 0, just the string you want the sha512 hash of
&binaryvar - A binary variable, used with N = 1, return the sha512 hash of the content of the binvar
filename - A filename, used with N = 2, return the sha512 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 SHA512 hash of plain text string abc to the active window:
//echo -a $sha512(abc) or //echo -a $sha512(abc,0)
The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC"
Echo the SHA512 hash of the zero-length null string to the active window:
//echo -a $sha512($null)
Echo the SHA512 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 $sha512(&snip,1)
Echo the SHA512 hash of the contents of the mIRC program you're running to the active window:
//echo -a $sha512($mircexe,2)
Note that because the default is N=0, $sha512($mircexe) is the SHA512 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 $sha512, 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 $sha512 differs from $crc in that it generates error for non-existent files instead of returning hash of $null string. Also, hex string returned by $sha512 is lowercase while $crc returns uppercase hex.
* Error accessing file: $sha512
Either file does not exist, or file permissions don't allow the file to be read. i.e. $sha512(non-existent-file,2) or $sha512(c:\hiberfil.sys,2)
* Invalid parameters: $sha512
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 Jul 2015
Note: Unless otherwise stated, this was the date of original functionality.
Further enhancements may have been made in later versions.