Updating hahsers INC files and Acknowledgements
INC files have been updated changing the information, adding new details. Acknowledgements file includes now Hashing Librarying license. Spacing consistency has been fixed in CPP Hashing files. Testsuite plug-in has been rewritten, now using Server Commands.
This commit is contained in:
parent
c071f53f2c
commit
38db4d3ae0
|
@ -2310,7 +2310,7 @@ native force_unmodified(force_type, const mins[3], const maxs[3], const filename
|
||||||
*
|
*
|
||||||
* @return Number of cells written to the buffer (always 32)
|
* @return Number of cells written to the buffer (always 32)
|
||||||
*/
|
*/
|
||||||
#pragma deprecated Use now hash_string() function. Also, see Hash_* constants.
|
#pragma deprecated Use hash_string() function. Also, see Hash_* constants.
|
||||||
native md5(const szString[], md5buffer[34]);
|
native md5(const szString[], md5buffer[34]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2322,14 +2322,14 @@ native md5(const szString[], md5buffer[34]);
|
||||||
* @return Number of cells written to the buffer (always 32)
|
* @return Number of cells written to the buffer (always 32)
|
||||||
* @error If the file can not be opened, and error is thrown.
|
* @error If the file can not be opened, and error is thrown.
|
||||||
*/
|
*/
|
||||||
#pragma deprecated Use now hash_file() function. Also, see Hash_* constants.
|
#pragma deprecated Use hash_file() function. Also, see Hash_* constants.
|
||||||
native md5_file(const file[], md5buffer[34]);
|
native md5_file(const file[], md5buffer[34]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashes a string.
|
* Generate a hash value (message digest)
|
||||||
*
|
*
|
||||||
* @param string String to hash.
|
* @param string String to be hashed.
|
||||||
* @param type Type of hash. See Hash_* constants in amxconst.inc file.
|
* @param type Type of selected hashing algorithm. See Hash_* constants in amxconst.inc file.
|
||||||
* @param output Output string to store hash in.
|
* @param output Output string to store hash in.
|
||||||
* @param outputSize The maximum size of the output string to store hash in.
|
* @param outputSize The maximum size of the output string to store hash in.
|
||||||
*
|
*
|
||||||
|
@ -2338,10 +2338,10 @@ native md5_file(const file[], md5buffer[34]);
|
||||||
native hash_string(const string[], const HashType:type, output[], const outputSize);
|
native hash_string(const string[], const HashType:type, output[], const outputSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashes a file's content (bytes).
|
* Generate a hash value using the contents of a given file
|
||||||
*
|
*
|
||||||
* @param fileName File to hash.
|
* @param fileName Path of file to be hashed.
|
||||||
* @param type Type of hash. See Hash_* constants in amxconst.inc file.
|
* @param type Type of selected hashing algorithm. See Hash_* constants in amxconst.inc file.
|
||||||
* @param output Output string to store hash in.
|
* @param output Output string to store hash in.
|
||||||
* @param outputSize The maximum size of the output string to store hash in.
|
* @param outputSize The maximum size of the output string to store hash in.
|
||||||
*
|
*
|
||||||
|
|
|
@ -9,39 +9,71 @@
|
||||||
|
|
||||||
#include <amxmodx>
|
#include <amxmodx>
|
||||||
|
|
||||||
|
new const g_hashTypes[HashType][] =
|
||||||
|
{
|
||||||
|
"CRC32",
|
||||||
|
"MD5",
|
||||||
|
"SHA1",
|
||||||
|
"SHA256",
|
||||||
|
"SHA3 224",
|
||||||
|
"SHA3 256",
|
||||||
|
"SHA3 384",
|
||||||
|
"SHA3 512",
|
||||||
|
"Keccak 224",
|
||||||
|
"Keccak 256",
|
||||||
|
"Keccak 384",
|
||||||
|
"Keccak 512"
|
||||||
|
};
|
||||||
|
|
||||||
public plugin_init()
|
public plugin_init()
|
||||||
{
|
{
|
||||||
register_plugin("Hashing Test", "1.0", "Hattrick (Claudiu HKS)");
|
register_plugin("Hashing Test", "1.0", "Hattrick (Claudiu HKS)");
|
||||||
|
register_srvcmd("hash_string", "cmdHashString");
|
||||||
|
register_srvcmd("hash_file", "cmdHashFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
public client_command(Id)
|
public cmdHashString()
|
||||||
{
|
{
|
||||||
new Command[64], StringOrFile[8], Data[64], HashTypeStr[4], Output[256], HashType:Type;
|
if (read_argc() < 2)
|
||||||
|
|
||||||
if (is_user_connected(Id) && !is_user_bot(Id) && !is_user_hltv(Id))
|
|
||||||
{
|
{
|
||||||
read_argv(0, Command, charsmax(Command));
|
server_print("Specify string to be hashed.");
|
||||||
read_argv(1, StringOrFile, charsmax(StringOrFile));
|
return PLUGIN_HANDLED;
|
||||||
read_argv(2, Data, charsmax(Data));
|
}
|
||||||
read_argv(3, HashTypeStr, charsmax(HashTypeStr));
|
|
||||||
|
|
||||||
if (equali(Command, "Hash"))
|
new String[256], Output[256], HashType:Type;
|
||||||
|
read_argv(1, String, charsmax(String));
|
||||||
|
|
||||||
|
log_amx("Hashing string %s...", String);
|
||||||
|
log_amx("-----------------------------------");
|
||||||
|
|
||||||
|
for (Type = Hash_Crc32; Type < any:sizeof g_hashTypes; Type++)
|
||||||
{
|
{
|
||||||
if (equali(StringOrFile, "File"))
|
hash_string(String, Type, Output, charsmax(Output));
|
||||||
|
log_amx("%s : %s", g_hashTypes[Type], Output);
|
||||||
|
}
|
||||||
|
|
||||||
|
return PLUGIN_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public cmdHashFile()
|
||||||
{
|
{
|
||||||
Type = HashType:str_to_num(HashTypeStr);
|
if (read_argc() < 2)
|
||||||
|
|
||||||
hash_file(Data, Type, Output, charsmax(Output));
|
|
||||||
log_amx("Original: %s Hashed: %s", Data, Output);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (equali(StringOrFile, "String"))
|
|
||||||
{
|
{
|
||||||
Type = HashType:str_to_num(HashTypeStr);
|
server_print("Specify file to be hashed.");
|
||||||
|
return PLUGIN_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
hash_string(Data, Type, Output, charsmax(Output));
|
new File[256], Output[256], HashType:Type;
|
||||||
log_amx("Original: %s Hashed: %s", Data, Output);
|
read_argv(1, File, charsmax(File));
|
||||||
}
|
|
||||||
}
|
log_amx("Hashing file %s...", File);
|
||||||
|
log_amx("-----------------------------------");
|
||||||
|
|
||||||
|
for (Type = Hash_Crc32; Type < any:sizeof g_hashTypes; Type++)
|
||||||
|
{
|
||||||
|
hash_file(File, Type, Output, charsmax(Output));
|
||||||
|
log_amx("%s : %s", g_hashTypes[Type], Output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return PLUGIN_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,3 +90,27 @@ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
|
||||||
|
--------------------------------------------------------------
|
||||||
|
Portable C++ Hashing Library, as used in AMX Mod X Core module
|
||||||
|
--------------------------------------------------------------
|
||||||
|
Copyright (c) 2014 Stephan Brumme
|
||||||
|
|
||||||
|
All source code published on http://create.stephan-brumme.com
|
||||||
|
and its sub-pages is licensed similar to the zlib license:
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the author be held liable for any damages arising from
|
||||||
|
the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
* The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software.
|
||||||
|
* If you use this software in a product, an acknowledgment in the product
|
||||||
|
documentation would be appreciated but is not required.
|
||||||
|
* Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user