From WikiChip
Difference between revisions of "mirc/identifiers/$sha384"
< mirc‎ | identifiers

(Created page with "{{mirc title|$sha384 identifier}}'''$sha384''' calculates the sha384 hash of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 40 lowe...")
 
(Error Messages)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{mirc title|$sha384 identifier}}'''$sha384''' calculates the [[sha384 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 40 lower-case hexadecimal characters.
+
{{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>
+
<source lang="mIRC">$sha384(plaintext|&binaryvar|filename,[N])</source>
  
 
== Parameters ==
 
== Parameters ==
'''plaintext''' - Used with N = 0, just the string you want the sha384 hash of
+
'''plaintext''' - Used with N = 0, the string for which you want the sha384 hash
  
'''&binaryvar''' - A binary variable, used with N = 1, return the sha384 hash of the content of the binvar
+
'''&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, return the sha384 hash of the content of the file
+
'''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:
<pre>//echo -a $sha384(abc)
+
<source lang="mIRC">//echo -a $sha384(abc)</source>
 
or
 
or
//echo -a $sha384(abc,0)</pre>
+
<source lang="mIRC">//echo -a $sha384(abc,0)</source>
 
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 SHA384 hash of the zero-length null string to the active window:
 
Echo the SHA384 hash of the zero-length null string to the active window:
<pre>//echo -a $sha384($null)</pre>
+
<source lang="mIRC">//echo -a $sha384($null)</source>
  
 
Echo the SHA384 hash of the first 1000 bytes of the mIRC program you're running to the active window:
 
Echo the SHA384 hash of the first 1000 bytes of the mIRC program you're running to the active window:
<pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</pre>
+
<source lang="mIRC">//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</source>
  
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>
+
<source lang="mIRC">//echo -a $sha384($mircexe,2)</source>
  
 
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 &string 1 chloé | echo -a $sha1(&string,1)</pre>
+
<source lang="mIRC">//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-)</source>
  
 
== Error Messages ==
 
== 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.
 
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.
  
<pre>* Error accessing file: $sha384</pre>
+
<source lang="mIRC">* Error accessing file: $sha384</source>
 
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)
 
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)
  
<pre>* Invalid parameters: $sha384</pre>
+
<source lang="mIRC">* Invalid parameters: $sha384</source>
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 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 52: Line 51:
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|7.42}}
 
{{mIRC compatibility|7.42}}
 
 
== See also ==
 
== See also ==
* {{mIRC|$crc}}
+
{{collist
* {{mIRC|$md5}}
+
|count = 3
 +
|style = width: 60%; display: inherit;
 +
|
 +
* {{mIRC|$sha1}}
 
* {{mIRC|$sha256}}
 
* {{mIRC|$sha256}}
 
* {{mIRC|$sha512}}
 
* {{mIRC|$sha512}}
* {{mIRC|$sha1}}
+
* {{mIRC|$hmac}}
* [[List of identifiers - mIRC]]
+
* {{mIRC|$hotp}}
{{mIRC identifier list}}
+
* {{mIRC|$totp}}
[[Category:mIRC identifiers|mircini]]
+
* {{mIRC|$md5}}
 +
* {{mIRC|$crc}}
 +
}}

Latest revision as of 16:57, 16 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[edit]

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

Parameters[edit]

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[edit]

None

Example[edit]

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[edit]

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[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.

See also[edit]