Hashers (AMX Mod X Scripting)
| 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_Crc32Provides CRC32 hashing Hash_Md5Provides MD5 hashing Hash_Sha1Provides SHA1 hashing Hash_Sha256Provides SHA256 hashing Hash_Sha3_224Provides SHA3 224 bit hashing Hash_Sha3_256Provides SHA3 256 bit hashing Hash_Sha3_384Provides SHA3 384 bit hashing Hash_Sha3_512Provides SHA3 512 bit hashing Hash_Keccak_224Provides Keccak 224 bit hashing Hash_Keccak_256Provides Keccak 256 bit hashing Hash_Keccak_384Provides Keccak 384 bit hashing Hash_Keccak_512Provides Keccak 512 bit hashing
Natives
hash_string(const string[], const HashType:type, output[], const outputSize)- Generates a hash value (message digest).
stringString to be hashed. typeType of selected hashing algorithm. See Hash_*constants above.outputOutput string to store hash in. outputSizeThe 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.
fileNamePath of file to be hashed. typeType of selected hashing algorithm. See Hash_*constants above.outputOutput string to store hash in. outputSizeThe 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));