19.02.2012, 15:29
(
Последний раз редактировалось RyDeR`; 23.02.2012 в 17:26.
)
Introduction
This include is an implementation of the PHP function hash. It provides a function to generate hash a value using HTTP with a simple piece of PHP code which you can see below.
Functions
Let's say, it has only one function (since it's not really a function as it works with different steps to generate the hash value):
Callback(s):
Here's a list of e_Algorithms:
And here are the defines:
If these are set before the include, your settings will be applied.
PHP Code
Currently this include is using my free hosted website so a small delay in retrieving the result is quite possible. I recommend you to use your own server for no delays. If you're planning to do that just save the following code as hash.php, upload it to your FTP and don't forget to change ryder.com.nu/
Examples
Here's a quick example usage of Whirlpool and MD5:
Your hash value be will generated under this callback:
will print us:
This is analog for the rest of the hash algorithms. You can use iIdx as playerid for register/login systems perhaps.
Download
Hash.inc
Register/Login System (Example)
Register/Login System Example using Hash.inc
Changelog
This include is an implementation of the PHP function hash. It provides a function to generate hash a value using HTTP with a simple piece of PHP code which you can see below.
Functions
Let's say, it has only one function (since it's not really a function as it works with different steps to generate the hash value):
pawn Код:
/*
const e_Algorithms: iAlgorithm The (name of the) algorithm your want to use
const iIdx The index of the process (perhaps it could be playerid for register/login systems)
szText[] The piece of text/string you want to hash
*/
stock Hash(const e_Algorithms: iAlgorithm, const iIdx, szText[]);
pawn Код:
forward OnHashUpdate(const iIdx, szHash[]);
pawn Код:
enum e_Algorithms {
MD2, MD4, MD5,
SHA1, SHA224, SHA256, SHA384, SHA512,
RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320,
WHIRLPOOL,
TIGER128_3, TIGER160_3, TIGER192_3,
TIGER128_4, TIGER160_4, TIGER192_4,
SNEFRU, SNEFRU256,
GOST,
ADLER32,
CRC32, CRC32B,
SALSA10, SALSA20,
HAVAL128_3, HAVAL160_3, HAVAL192_3, HAVAL224_3, HAVAL256_3,
HAVAL128_4, HAVAL160_4, HAVAL192_4, HAVAL224_4, HAVAL256_4,
HAVAL128_5, HAVAL160_5, HAVAL192_5, HAVAL224_5, HAVAL256_5
};
pawn Код:
#if !defined MAX_HTTP_SIZE
#define MAX_HTTP_SIZE (1024)
#endif
#if !defined HASH_SERVER
#define HASH_SERVER "ryder.com.nu/hash.php"
#endif
PHP Code
Currently this include is using my free hosted website so a small delay in retrieving the result is quite possible. I recommend you to use your own server for no delays. If you're planning to do that just save the following code as hash.php, upload it to your FTP and don't forget to change ryder.com.nu/
PHP код:
<?php
echo(hash($_POST["algo"], $_POST["data"]));
?>
Here's a quick example usage of Whirlpool and MD5:
pawn Код:
Hash(MD5, 10000,
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
);
Hash(WHIRLPOOL, 10001,
"The quick brown fox jumps over the lazy dog"
);
pawn Код:
public OnHashUpdate(const iIdx, szHash[]) {
switch(iIdx) {
case 10000: {
printf("MD5: %s", szHash);
}
case 10001: {
printf("Whirlpool: %s", szHash);
}
}
}
pawn Код:
MD5: fa5c89f3c88b81bfd5e821b0316569af
Whirlpool: b97de512e91e3828b40d2b0fdce9ceb3c4a71f9bea8d88e75c4fa854df36725fd2b52eb6544edcacd6f8beddfea403cb55ae31f03ad62a5ef54e42ee82c3fb35
Download
Hash.inc
Register/Login System (Example)
Register/Login System Example using Hash.inc
Changelog
- 19/02/2011:
- Initial release
- 23/02/2011 (Important update!):
- Fixes:
- Security issues regarding hash values in Apache logs (Thanks to Slice!).
- PHP Code
- Adds:
- URL Encoding for string validating so hash values don't get messed up.
- Notes:
- Nothing has been changed about the syntax: after update, no need to change anything.
- Fixes: