Squirrel/Server/Functions/Hashing/MD5
From Liberty Unleashed Wiki
(Difference between revisions)
(Created page with '{{Squirrel/Title|MD5}} {{RequiresModule|lu_hashing|Modules/Squirrel/lu_hashing}} This function returns an MD5 hash value of the given string. This is useful for example when stor…') |
(→Example) |
||
Line 13: | Line 13: | ||
== Example == | == Example == | ||
− | {{ | + | <code lang="squirrel> |
+ | function onPlayerCommand( pPlayer, szCommand, szText ) | ||
+ | { | ||
+ | if ( szCommand == "hash" ) | ||
+ | { | ||
+ | if ( szText ) MessagePlayer( "The MD5 of " + szText + " is " + MD5( szText ), pPlayer ); | ||
+ | } | ||
+ | |||
+ | return 1; | ||
+ | } | ||
+ | </code> | ||
=== Notes === | === Notes === | ||
− | + | The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. | |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Hashing}} | {{Squirrel/Server/Functions/Hashing}} |
Revision as of 15:45, 29 September 2010
Note: This function requires the external module lu_hashing.
This function returns an MD5 hash value of the given string. This is useful for example when storing account passwords.
Syntax
string MD5( string text )
Arguments
- text - The string to be hashed
Example
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "hash" ) { if ( szText ) MessagePlayer( "The MD5 of " + szText + " is " + MD5( szText ), pPlayer ); } return 1; }
Notes
The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
Related Functions
These functions are provided by the official module lu_hashing.
- MD5
- SHA1