From WikiChip
Editing mirc/identifiers/$sha512
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|$sha512 identifier}}'''$sha512''' calculates the [[sha512 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 40 lower-case hexadecimal characters. | {{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 40 lower-case hexadecimal characters. | ||
− | |||
== Synopsis == | == Synopsis == | ||
Line 20: | Line 19: | ||
== Example == | == Example == | ||
− | Echo the | + | Echo the SHA1 hash of plain text string ''abc'' to the active window: |
− | <pre>//echo -a $ | + | <pre>//echo -a $sha1(abc) |
or | or | ||
− | //echo -a $ | + | //echo -a $sha1(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 SHA1 hash of the zero-length null string to the active window: |
− | <pre>//echo -a $ | + | <pre>//echo -a $sha1($null)</pre> |
+ | |||
+ | Echo the SHA1 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 $sha1(&snip,1)</pre> | ||
− | Echo the | + | Echo the SHA1 hash of the contents of the mIRC program you're running to the active window: |
− | <pre>// | + | <pre>//echo -a $sha1($mircexe,2)</pre> |
− | + | Suggested Uses: | |
− | < | + | * Quick way to compare if 2 files are identical. (First check should always be comparing file sizes.) |
+ | * Quick way to check if a file's contents have changed since stored sha1 hash was made. | ||
+ | * Verify downloaded file hasn't been corrupted, matches the sender's original. | ||
+ | <br /> | ||
+ | Note that because the default is N=0, '''$sha1($mircexe)''' is the SHA1 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 plaintext before providing to $sha1, so v7.x and v6.x return different answers for //echo -a $sha1($chr(233))<br /> | ||
− | + | If the text doesn't have Unicode code points above 255, to avoid having Unicode points 128-255 encoded to 2-byte pairs, the text must be fed to $sha1 as a binary variable:<br /> | |
− | |||
<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 $sha1 differs from $crc in that it generates error for non-existent files instead of returning hash of $null string. Also, hex string returned by $sha1 is lowercase while $crc returns uppercase hex. |
− | <pre>* Error accessing file: $ | + | <pre>* Error accessing file: $sha1</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. $sha1(non-existent-file,2) or $sha1(c:\hiberfil.sys,2) |
− | <pre>* Invalid parameters: $ | + | <pre>* Invalid parameters: $sha1</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 52: | Line 58: | ||
== Compatibility == | == Compatibility == | ||
− | {{mIRC compatibility| | + | {{mIRC compatibility|6.3}} |
== See also == | == See also == | ||
Line 59: | Line 65: | ||
* {{mIRC|$sha256}} | * {{mIRC|$sha256}} | ||
* {{mIRC|$sha384}} | * {{mIRC|$sha384}} | ||
− | * {{mIRC|$ | + | * {{mIRC|$sha512}} |
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
− | [[Category:mIRC identifiers| | + | [[Category:mIRC identifiers|mircini]] |