From WikiChip
Editing mirc/identifiers/$sha1
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: | ||
− | |||
== Synopsis == | == Synopsis == | ||
− | <pre>$sha1(plaintext|&binaryvar|filename,[N])</pre> | + | <pre>$sha1(plaintext|&binaryvar|filename,[N]) |
+ | Returns the sha1 hash for the specified data, where N = 0 for plain text (default), 1 for &binary variable, 2 for filename. | ||
+ | </pre> | ||
+ | Hash is 160-bits, shown as 40 hexadecimal characters. | ||
+ | |||
== Parameters == | == Parameters == | ||
− | ''' | + | '''Required:''' Data<br /> |
+ | '''Optional:''' Integer 0-2, where 0 (default) indicates data is plaintext, 1 indicates a &binary variable, 2 indicates contents of a filename | ||
− | + | == Properties == | |
− | + | None | |
− | |||
− | |||
− | |||
− | |||
− | |||
== Example == | == Example == | ||
Echo the SHA1 hash of plain text string ''abc'' to the active window: | Echo the SHA1 hash of plain text string ''abc'' to the active window: | ||
Line 19: | Line 18: | ||
or | or | ||
//echo -a $sha1(abc,0)</pre> | //echo -a $sha1(abc,0)</pre> | ||
− | + | $sha1 is case-sensitive, so hash of "abc" is different than hash of "ABC" | |
+ | |||
+ | Echo the SHA1 hash of the zero-length nul string to the active window: | ||
+ | <pre>//echo -a $sha1($nul)</pre> | ||
Echo the SHA1 hash of the contents of the mIRC program you're running to the active window: | Echo the SHA1 hash of the contents of the mIRC program you're running to the active window: | ||
Line 25: | Line 27: | ||
Echo the SHA1 hash of the first 1000 bytes of the mIRC program you're running to the active window: | 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>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha1(&snip,1)</pre> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Suggested Uses: | Suggested Uses: | ||
* Quick way to compare if 2 files are identical. (First check should always be comparing file sizes.) | * 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. | * 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 | + | * Verify downloaded file hasn't been corrupted, matches the sender's original. |
<br /> | <br /> | ||
− | Note that | + | Note that $sha1($mircexe) is the same as the SHA1 hash for the text string of the drive:\path\filename for the mIRC you're running, regardless of file contents.<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 /> | 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 /> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Error Messages == | == Error Messages == | ||
− | Note that $sha1 differs from $crc in that it generates error for non-existent files instead of returning hash of $ | + | Note that $sha1 differs from $crc in that it generates error for non-existent files instead of returning hash of $nul string. Also, in absence of specifying index 0-2, $sha1's default is 0 while $crc's default is 2. Also, hex string returned by $sha1 is lowercase while $crc returns uppercase. |
<pre>* Error accessing file: $sha1</pre> | <pre>* Error accessing file: $sha1</pre> | ||
Line 64: | Line 47: | ||
<pre>Both above errors halt execution of the script</pre> | <pre>Both above errors halt execution of the script</pre> | ||
− | |||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|6.3}} | {{mIRC compatibility|6.3}} | ||
− | == See | + | |
− | {{ | + | == See also == |
− | | | + | * {{mIRC|$crc}} |
− | + | * {{mIRC|$md5}} | |
− | | | ||
* {{mIRC|$sha256}} | * {{mIRC|$sha256}} | ||
+ | * {{mIRC|$sha384}} | ||
* {{mIRC|$sha512}} | * {{mIRC|$sha512}} | ||
− | * | + | * [[List of identifiers - mIRC]] |
− | + | {{mIRC identifier list}} | |
− | |||
− | |||
− | |||
− | |||
− | }} |