From WikiChip
Editing mirc/identifiers/$crc
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|$crc Identifier}}'''$crc''' calculates the [[32-bit checksum]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 32-bits, shown as 8 upper-case hexadecimal characters. | + | {{mirc title|$crc Identifier}} |
− | + | The '''$crc''' identifier calculates the [[32-bit checksum]] of a text, {{mirc|binary variables|binary variable}}, or file. Hash is 32-bits, shown as 8 upper-case hexadecimal characters. | |
== Synopsis == | == Synopsis == | ||
− | <pre>$crc(plaintext|&binaryvar|filename[,N])</pre> | + | <pre>$crc(plaintext|&binaryvar|filename[,N]) |
+ | </pre> | ||
== Parameters == | == Parameters == | ||
Line 17: | Line 18: | ||
== Properties == | == Properties == | ||
+ | |||
None | None | ||
== Example == | == Example == | ||
− | + | Echo the $crc hash of plain text string ''abc'' to the active window: | |
− | + | <pre>//echo -a $crc(abc,0) | |
− | + | </pre> | |
− | + | The DATA is case-sensitive, so hash of "abc" is different than hash of "ABC" | |
− | |||
− | + | Echo the CRC-32 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 $crc(&snip,1)</pre> | |
− | // | ||
− | </ | ||
− | + | Echo the CRC-32 hash of the contents of the mIRC program you're running to the active window: | |
− | + | <pre>//echo -a $crc($mircexe,2) | |
− | //echo -a | + | or |
− | + | //echo -a $crc($mircexe) | |
− | + | </pre> | |
− | //echo -a | ||
− | </ | ||
Returns 00000000 if filename does not exist: | Returns 00000000 if filename does not exist: | ||
− | <pre> | + | <pre>//echo -a $crc(no_such_file.txt,2) |
− | //echo -a $crc(no_such_file.txt,2) | + | |
− | |||
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.) | ||
Line 48: | Line 44: | ||
* Verify downloaded file hasn't been corrupted, matches the sender's original. | * Verify downloaded file hasn't been corrupted, matches the sender's original. | ||
<br /> | <br /> | ||
− | + | Note that because the default is N=2, '''$crc(versions.txt)''' is the CRC-32 for the contents of versions.txt (or 00000000 if the file doesn't exist). This differs from $sha1(versions.txt) giving the hash of the plaintext inside the parenthesis because $sha1 has default of N=0.<br /> | |
mIRC v7.x Unicode-encodes plaintext before providing to $crc, so v7.x and v6.x return different answers for //echo -a $crc($chr(233),0)<br /> | mIRC v7.x Unicode-encodes plaintext before providing to $crc, so v7.x and v6.x return different answers for //echo -a $crc($chr(233),0)<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 $crc as a binary variable:<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 $crc as a binary variable:<br /> | ||
− | <pre> | + | <pre>//bset -ta &string 1 chloé | echo -a $crc(&string,1)</pre> |
− | // | ||
− | </pre> | ||
− | |||
− | |||
== Error Messages == | == Error Messages == | ||
Line 69: | Line 61: | ||
== Compatibility == | == Compatibility == | ||
− | + | {{mIRC compatibility|5.6}} for $crc(filename) | |
− | {{mIRC compatibility|5.6}} | + | {{mIRC compatibility|6.1}} for N=0-2 parameter |
− | |||
− | {{mIRC compatibility|6.1}} | ||
== See also == | == See also == | ||
Line 82: | Line 72: | ||
* [[List of identifiers - mIRC]] | * [[List of identifiers - mIRC]] | ||
{{mIRC identifier list}} | {{mIRC identifier list}} | ||
− |