m |
Maroonbells (talk | contribs) (Add'l info) |
||
Line 1: | Line 1: | ||
− | {{mirc title|$sha384 identifier}}'''$sha384''' calculates the | + | {{mirc title|$sha384 identifier}}'''$sha384''' calculates the sha384 hash of a text string, {{mirc|binary variables|binary variable}}, or disk file. The hash digest is 384-bits, shown as 96 lower-case hexadecimal characters. |
− | |||
− | |||
== Synopsis == | == Synopsis == | ||
<pre>$sha384(plaintext|&binaryvar|filename,[N])</pre> | <pre>$sha384(plaintext|&binaryvar|filename,[N])</pre> | ||
− | |||
== Parameters == | == Parameters == | ||
− | '''plaintext''' - Used with N = 0, | + | '''plaintext''' - Used with N = 0, the string for which you want the sha384 hash |
− | '''&binaryvar''' - A binary variable, used with N = 1, | + | '''&binaryvar''' - A binary variable, used with N = 1, returns the sha384 hash of the content of the binvar |
− | '''filename''' - A filename, used with N = 2, | + | '''filename''' - A filename, used with N = 2, returns the sha384 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<br /> | + | '''N:''' Default 0. 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<br /> |
If the N parameter isn't used, the default 0 is used (which is different than $crc which has default of N=2.) | If the N parameter isn't used, the default 0 is used (which is different than $crc which has default of N=2.) | ||
+ | * Note: sha384 is a 'one way' cryptographic hash that's part of the SHA2 family, which also contains the sha224 sha256 and sha512 hashes, of which mIRC has not added sha224. sha384 is identical to the sha512 hash except for having a different initial 512-bit 'magic' constant, and that the hash digest displays only 6 of the 64-bit hashing variables instead of displaying all 8. This makes it no faster or slower than sha512, and no less or more secure than using the first 96 digits of the sha512 hash. Due to the 64 hex digits which aren't displayed, sha384 has 128 bits of strength against the 'length extension' attack, which is an attack against incorrect authentication using $sha384(<secret> <public string>) instead of using $hmac(public string, secret, sha512). | ||
== Properties == | == Properties == | ||
None | None | ||
− | |||
== Example == | == Example == | ||
Echo the SHA384 hash of plain text string ''abc'' to the active window: | Echo the SHA384 hash of plain text string ''abc'' to the active window: | ||
Line 32: | Line 29: | ||
<pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</pre> | <pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</pre> | ||
− | Echo the SHA384 hash of the contents of the mIRC program you're running to the active window: | + | Echo the SHA384 hash of the contents of the entire mIRC program you're running to the active window: |
<pre>//echo -a $sha384($mircexe,2)</pre> | <pre>//echo -a $sha384($mircexe,2)</pre> | ||
Note that because the default is N=0, '''$sha384($mircexe)''' is the SHA384 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 /> | Note that because the default is N=0, '''$sha384($mircexe)''' is the SHA384 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 $sha384, 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. | + | mIRC v7.x Unicode-encodes bytes 128-255 to utf8 before providing to $sha384, if the text doesn't have code points above 255, you can avoid the utf8 encoding issue by using /bset to create a binvar with the -a switch. |
− | <pre>//bset -ta & | + | <pre>//var %a chloé | bset -t &bin1 1 %a | bset -ta &bin2 1 %a | echo -a $sha1(&bin1,1) vs $sha1(&bin2,1) or $bvar(&bin1,1-) vs $bvar(&bin2,1-)</pre> |
== Error Messages == | == Error Messages == | ||
Line 47: | Line 44: | ||
<pre>* Invalid parameters: $sha384</pre> | <pre>* Invalid parameters: $sha384</pre> | ||
− | Either using a zero-length/non-existent binary variable or specifying an N | + | Either using a zero-length/non-existent binary variable or specifying an N outside the 0-2 valid range. |
<pre>Both above errors halt execution of the script</pre> | <pre>Both above errors halt execution of the script</pre> | ||
Line 53: | Line 50: | ||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|7.42}} | {{mIRC compatibility|7.42}} | ||
− | |||
== See also == | == See also == | ||
− | + | {{collist | |
− | * {{mIRC|$ | + | |count = 3 |
+ | |style = width: 60%; display: inherit; | ||
+ | | | ||
+ | * {{mIRC|$sha1}} | ||
* {{mIRC|$sha256}} | * {{mIRC|$sha256}} | ||
* {{mIRC|$sha512}} | * {{mIRC|$sha512}} | ||
− | * {{mIRC|$ | + | * {{mIRC|$hmac}} |
− | * | + | * {{mIRC|$hotp}} |
− | {{mIRC | + | * {{mIRC|$totp}} |
− | + | * {{mIRC|$md5}} | |
+ | * {{mIRC|$crc}} | ||
+ | }} |
Revision as of 15:47, 13 August 2018
$sha384 calculates the sha384 hash of a text string, binary variable, or disk file. The hash digest is 384-bits, shown as 96 lower-case hexadecimal characters.
Synopsis
$sha384(plaintext|&binaryvar|filename,[N])
Parameters
plaintext - Used with N = 0, the string for which you want the sha384 hash
&binaryvar - A binary variable, used with N = 1, returns the sha384 hash of the content of the binvar
filename - A filename, used with N = 2, returns the sha384 hash of the content of the file
N: Default 0. 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.)
- Note: sha384 is a 'one way' cryptographic hash that's part of the SHA2 family, which also contains the sha224 sha256 and sha512 hashes, of which mIRC has not added sha224. sha384 is identical to the sha512 hash except for having a different initial 512-bit 'magic' constant, and that the hash digest displays only 6 of the 64-bit hashing variables instead of displaying all 8. This makes it no faster or slower than sha512, and no less or more secure than using the first 96 digits of the sha512 hash. Due to the 64 hex digits which aren't displayed, sha384 has 128 bits of strength against the 'length extension' attack, which is an attack against incorrect authentication using $sha384(<secret> <public string>) instead of using $hmac(public string, secret, sha512).
Properties
None
Example
Echo the SHA384 hash of plain text string abc to the active window:
//echo -a $sha384(abc) or //echo -a $sha384(abc,0)
The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC"
Echo the SHA384 hash of the zero-length null string to the active window:
//echo -a $sha384($null)
Echo the SHA384 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 $sha384(&snip,1)
Echo the SHA384 hash of the contents of the entire mIRC program you're running to the active window:
//echo -a $sha384($mircexe,2)
Note that because the default is N=0, $sha384($mircexe) is the SHA384 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 $sha384, if the text doesn't have code points above 255, you can avoid the utf8 encoding issue by using /bset to create a binvar with the -a switch.
//var %a chloé | bset -t &bin1 1 %a | bset -ta &bin2 1 %a | echo -a $sha1(&bin1,1) vs $sha1(&bin2,1) or $bvar(&bin1,1-) vs $bvar(&bin2,1-)
Error Messages
Note that $sha384 differs from $crc in that it generates error for non-existent files instead of returning hash of $null string. Also, hex string returned by $sha384 is lowercase while $crc returns uppercase hex.
* Error accessing file: $sha384
Either file does not exist, or file permissions don't allow the file to be read. i.e. $sha384(non-existent-file,2) or $sha384(c:\hiberfil.sys,2)
* Invalid parameters: $sha384
Either using a zero-length/non-existent binary variable or specifying an N outside the 0-2 valid range.
Both above errors halt execution of the script
Compatibility
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.