From WikiChip
Editing mirc/identifiers/$sha384

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{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.
+
{{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.
 +
 
 
== Synopsis ==
 
== Synopsis ==
<source lang="mIRC">$sha384(plaintext|&binaryvar|filename,[N])</source>
+
<pre>$sha384(plaintext|&binaryvar|filename,[N])</pre>
  
 
== Parameters ==
 
== Parameters ==
'''plaintext''' - Used with N = 0, the string for which you want the sha384 hash
+
'''plaintext''' - Used with N = 0, just the string you want the sha384 hash of
  
'''&binaryvar''' - A binary variable, used with N = 1, returns the sha384 hash of the content of the binvar
+
'''&binaryvar''' - A binary variable, used with N = 1, return 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
+
'''filename''' - A filename, used with N = 2, return 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<br />
+
'''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 />
  
 
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:
<source lang="mIRC">//echo -a $sha384(abc)</source>
+
<pre>//echo -a $sha384(abc)
 
or
 
or
<source lang="mIRC">//echo -a $sha384(abc,0)</source>
+
//echo -a $sha384(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 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:
<source lang="mIRC">//echo -a $sha384($null)</source>
+
<pre>//echo -a $sha384($null)</pre>
  
 
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:
<source lang="mIRC">//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</source>
+
<pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha384(&snip,1)</pre>
  
Echo the SHA384 hash of the contents of the entire mIRC program you're running to the active window:
+
Echo the SHA384 hash of the contents of the mIRC program you're running to the active window:
<source lang="mIRC">//echo -a $sha384($mircexe,2)</source>
+
<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 /bset to create 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 a binvar with the -a switch.
  
<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>
+
<pre>//bset -ta &string 1 chloé | echo -a $sha1(&string,1)</pre>
  
 
== 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.
  
<source lang="mIRC">* Error accessing file: $sha384</source>
+
<pre>* Error accessing file: $sha384</pre>
 
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)
  
<source lang="mIRC">* Invalid parameters: $sha384</source>
+
<pre>* Invalid parameters: $sha384</pre>
Either using a zero-length/non-existent binary variable or specifying an N outside the 0-2 valid range.
+
Either using a zero-length/non-existent binary variable or specifying an N where $int(%N) isn't 0-2.
  
 
<pre>Both above errors halt execution of the script</pre>
 
<pre>Both above errors halt execution of the script</pre>
Line 51: Line 52:
 
== Compatibility ==
 
== Compatibility ==
 
{{mIRC compatibility|7.42}}
 
{{mIRC compatibility|7.42}}
 +
 
== See also ==
 
== See also ==
{{collist
+
* {{mIRC|$crc}}
|count = 3
+
* {{mIRC|$md5}}
|style = width: 60%; display: inherit;
 
|
 
* {{mIRC|$sha1}}
 
 
* {{mIRC|$sha256}}
 
* {{mIRC|$sha256}}
 
* {{mIRC|$sha512}}
 
* {{mIRC|$sha512}}
* {{mIRC|$hmac}}
+
* {{mIRC|$sha1}}
* {{mIRC|$hotp}}
+
* [[List of identifiers - mIRC]]
* {{mIRC|$totp}}
+
{{mIRC identifier list}}
* {{mIRC|$md5}}
+
[[Category:mIRC identifiers|mircini]]
* {{mIRC|$crc}}
 
}}
 

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)