Md5: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Example added)
No edit summary
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
Calculates the MD5 hash of the specified string and returns its hexadecimal representation.
Calculates the MD5 hash of the specified string and returns its hexadecimal representation.
 
{{Warning|It is strongly recommended to use passwordHash to hash passwords, md5 is easily decodeable.}}
Note: returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been MD5'd elsewhere.
{{Note|It returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been MD5'd elsewhere.}}


==Syntax==
==Syntax==
Line 17: Line 16:
==Example==
==Example==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function md5it (player,command,string) -- open function
function md5it (player,command, theString) -- open function
   if (string) then -- check if the string is exist
   if theString then -- check if the string is exist
     md5string = md5 (string) -- get the md5 string
     md5string = md5(theString) -- get the md5 string
     outputChatBox (string .. " -> " .. md5string ,player,255,0,0,false) -- output it
     outputChatBox(theString.. " -> " .. md5string , player, 255, 0, 0, false) -- output it
   end
   end
end
end
addCommandHandler ("md5it",md5it) -- create command
addCommandHandler ("md5it", md5it) -- create command
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Utility functions}}
{{Utility functions}}
[[Category:Needs Example]]

Revision as of 05:21, 11 August 2019

Calculates the MD5 hash of the specified string and returns its hexadecimal representation.

[[|link=|]] Warning: It is strongly recommended to use passwordHash to hash passwords, md5 is easily decodeable.
[[{{{image}}}|link=|]] Note: It returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been MD5'd elsewhere.

Syntax

string md5 ( string str )

Required Arguments

  • str: the string to hash.

Returns

Returns the MD5 hash of the input string if successful, false otherwise.

Example

function md5it (player,command, theString) -- open function
  if theString then -- check if the string is exist
    md5string = md5(theString) -- get the md5 string
    outputChatBox(theString.. " -> " .. md5string , player, 255, 0, 0, false) -- output it
  end
end
addCommandHandler ("md5it", md5it) -- create command

See Also