Difference between revisions of "Hashers (AMX Mod X Scripting)"
(Added Hashers documentation) |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
__FORCETOC__ | __FORCETOC__ | ||
− | {{Languages| | + | {{Languages|Hashers (AMX Mod X Scripting)}} |
Line 45: | Line 45: | ||
=== Natives === | === Natives === | ||
− | {{margin|20px 0 15px 0|{{tt|hash_string(const string[], const {{color|green|HashType}}:type, output[], const outputSize)|opt=large}}}} | + | {{margin|20px 0 15px 0|{{tt|hash_string(const {{h:title||string}}[], const {{color|green|HashType}}:{{h:title||type}}, {{h:title||output}}[], const {{h:title||outputSize}})|opt=large}}}} |
: Generates a hash value (message digest). | : Generates a hash value (message digest). | ||
Line 63: | Line 63: | ||
:{{alert|success|Example:|{{tt|new hash[32];<br />new const message[] <nowiki>=</nowiki> "Hello World!";<br />new const length <nowiki>=</nowiki> hash_string(message, Hash_Md5, hash, charsmax(hash));|opt=nobg}}|opt=full-border}} | :{{alert|success|Example:|{{tt|new hash[32];<br />new const message[] <nowiki>=</nowiki> "Hello World!";<br />new const length <nowiki>=</nowiki> hash_string(message, Hash_Md5, hash, charsmax(hash));|opt=nobg}}|opt=full-border}} | ||
− | {{margin|35px 0 15px 0|{{tt|hash_file(const fileName[], const {{color|green|HashType}}:type, output[], const outputSize)|opt=large}}}} | + | {{margin|35px 0 15px 0|{{tt|hash_file(const {{h:title||fileName}}[], const {{color|green|HashType}}:{{h:title||type}}, {{h:title||output}}[], const {{h:title||outputSize}})|opt=large}}}} |
: Generates a hash value using the contents of a given file. | : Generates a hash value using the contents of a given file. | ||
Latest revision as of 12:18, 18 June 2017
Language: | English • français |
---|
Contents
About
Hashers provide a way to generate a hash value from a string or file content, available in amxmodx.inc.
Note:The following API deprecates
md5
and md5_file
natives.Usage
Hashes
The available HashType
constants are:
Hash_Crc32
Provides CRC32 hashing Hash_Md5
Provides MD5 hashing Hash_Sha1
Provides SHA1 hashing Hash_Sha256
Provides SHA256 hashing Hash_Sha3_224
Provides SHA3 224 bit hashing Hash_Sha3_256
Provides SHA3 256 bit hashing Hash_Sha3_384
Provides SHA3 384 bit hashing Hash_Sha3_512
Provides SHA3 512 bit hashing Hash_Keccak_224
Provides Keccak 224 bit hashing Hash_Keccak_256
Provides Keccak 256 bit hashing Hash_Keccak_384
Provides Keccak 384 bit hashing Hash_Keccak_512
Provides Keccak 512 bit hashing
Natives
hash_string(const string[], const HashType:type, output[], const outputSize)
- Generates a hash value (message digest).
string
String to be hashed. type
Type of selected hashing algorithm. See Hash_*
constants above.output
Output string to store hash in. outputSize
The maximum size of the output string to store hash in.
- Return:Number of written bytes.
- Example:
new hash[32];
new const message[] = "Hello World!";
new const length = hash_string(message, Hash_Md5, hash, charsmax(hash));
hash_file(const fileName[], const HashType:type, output[], const outputSize)
- Generates a hash value using the contents of a given file.
fileName
Path of file to be hashed. type
Type of selected hashing algorithm. See Hash_*
constants above.output
Output string to store hash in. outputSize
The maximum size of the output string to store hash in.
- Return:Number of written bytes.
- Note:Path of file is relative to
$mod/
directory. - Example:
new hash[32];
new const fileName[] = "server.cfg";
new const length = hash_file(message, Hash_Md5, hash, charsmax(hash));