Md5: Difference between revisions
Jump to navigation
Jump to search
m (Needs example) |
No edit summary |
||
(6 intermediate revisions by 5 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 | {{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 14: | Line 13: | ||
===Returns=== | ===Returns=== | ||
Returns the MD5 hash of the input string if successful, ''false'' otherwise. | Returns the MD5 hash of the input string if successful, ''false'' otherwise. | ||
==Remarks== | |||
This function, along with other hashing algorithms, can be used for a '''plausible script self protection''' strategy. If done right this strategy does present the fact that the script wants to express ownership to a legal entity. This can be used as argument in a court of law or for DRM purposes. You can find the general idea [https://forum.mtasa.com/topic/132891-important-helprespawn-vehicle/?do=findComment&comment=1002490 here]. | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | 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 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Utility functions}} | {{Utility functions}} | ||
Latest revision as of 13:46, 20 October 2021
Calculates the MD5 hash of the specified string and returns its hexadecimal representation.
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.
Remarks
This function, along with other hashing algorithms, can be used for a plausible script self protection strategy. If done right this strategy does present the fact that the script wants to express ownership to a legal entity. This can be used as argument in a court of law or for DRM purposes. You can find the general idea here.
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
- addDebugHook
- base64Decode
- base64Encode
- debugSleep
- decodeString
- encodeString
- fromJSON
- generateKeyPair
- getColorFromString
- getDevelopmentMode
- getDistanceBetweenPoints2D
- getDistanceBetweenPoints3D
- getEasingValue
- getNetworkStats
- getNetworkUsageData
- getPerformanceStats
- getRealTime
- getTickCount
- getTimerDetails
- getTimers
- getFPSLimit
- getUserdataType
- getVersion
- gettok
- isTransferBoxVisible
- setTransferBoxVisible
- hash
- inspect
- interpolateBetween
- iprint
- isOOPEnabled
- isTimer
- killTimer
- md5
- passwordHash
- passwordVerify
- pregFind
- pregMatch
- pregReplace
- removeDebugHook
- resetTimer
- setDevelopmentMode
- setFPSLimit
- setTimer
- ref
- deref
- sha256
- split
- teaDecode
- teaEncode
- toJSON
- tocolor
- getProcessMemoryStats
- utfChar
- utfCode
- utfLen
- utfSeek
- utfSub
- bitAnd
- bitNot
- bitOr
- bitXor
- bitTest
- bitLRotate
- bitRRotate
- bitLShift
- bitRShift
- bitArShift
- bitExtract
- bitReplace