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: | ||
{{mirc title|$sha1 identifier}}'''$sha1''' calculates the [[sha1 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 40 lower-case hexadecimal characters. | {{mirc title|$sha1 identifier}}'''$sha1''' calculates the [[sha1 hash]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 160-bits, shown as 40 lower-case hexadecimal characters. | ||
+ | |||
+ | |||
== Synopsis == | == Synopsis == | ||
<pre>$sha1(plaintext|&binaryvar|filename,[N])</pre> | <pre>$sha1(plaintext|&binaryvar|filename,[N])</pre> | ||
+ | |||
== Parameters == | == Parameters == | ||
'''plaintext''' - Used with N = 0, just the string you want the sha1 hash of | '''plaintext''' - Used with N = 0, just the string you want the sha1 hash of | ||
Line 9: | Line 12: | ||
'''filename''' - A filename, used with N = 2, return the sha1 hash of the content of the file | '''filename''' - A filename, used with N = 2, return the sha1 hash of the content of the file | ||
− | '''N:''' Optional integer 0-2, where 0 | + | '''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.) | ||
+ | |||
== Properties == | == Properties == | ||
None | 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 21: | Line 26: | ||
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 SHA1 hash of the | + | Echo the SHA1 hash of the zero-length null string to the active window: |
− | <pre>//echo -a $sha1($ | + | <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: | 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 | + | <pre>//bread $qt($mircexe) 0 1000 &snip | echo -a $sha1(&snip,1)</pre> |
− | + | Echo the SHA1 hash of the contents of the mIRC program you're running to the active window: | |
− | + | <pre>//echo -a $sha1($mircexe,2)</pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | <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 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 /> | 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 /> | ||
Line 47: | Line 46: | ||
<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 == | ||
Line 64: | Line 57: | ||
<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}} | |
− | + | [[Category:mIRC identifiers|sha1]] | |
− | |||
− | |||
− | |||
− |