Sha256: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Server client function}} {{MessageBox| bordercolorhex = FF0000 | bordertype = dotted | bgcolorhex = CCCCFF | image = File:Dialog-information.png | tit...")
 
(Remove obsolete Requirements section)
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
{{Server client function}}
 
{{Tip|
{{MessageBox|
* The sha module and this function may conflict with eachother, if you use this function uninstall the module!
  bordercolorhex = FF0000 |
* This function returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been sha256'd elsewhere.}}
  bordertype = dotted |
  bgcolorhex = CCCCFF |
  image = File:Dialog-information.png |
  title = Warning regarding the sha module |
  subtext = The sha module and this function may conflict with eachother, if you use this function uninstall the module! |
}}
 


Calculates the sha256 hash of the specified string.
Calculates the sha256 hash of the specified string.
'''Note:''' returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been sha256'd elsewhere.


==Syntax==
==Syntax==
Line 31: Line 21:
function ( thePlayer, command, input )
function ( thePlayer, command, input )
if ( input ) then -- Check if the string exist
if ( input ) then -- Check if the string exist
local hash = sha256( input ) -- Generate the hash
local sha256hash = sha256( input ) -- Generate the hash
outputChatBox( hash ) -- Output the hash in the chat
outputChatBox( sha256hash ) -- Output the hash in the chat
end
end
end
end
Line 40: Line 30:
==See Also==
==See Also==
{{Utility functions}}
{{Utility functions}}
[[en:sha256]]
[[ru:sha256]]

Latest revision as of 17:08, 7 November 2024

[[{{{image}}}|link=|]] Tip:
  • The sha module and this function may conflict with eachother, if you use this function uninstall the module!
  • This function returns an uppercase string, so make sure you string.upper() anything else you are checking against that has been sha256'd elsewhere.

Calculates the sha256 hash of the specified string.

Syntax

string sha256 ( string str )

Required Arguments

  • str: the string to hash.

Returns

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

Example

addCommandHandler ( "sha", -- Create a command
	function ( thePlayer, command, input )
		if ( input ) then -- Check if the string exist
			local sha256hash = sha256( input ) -- Generate the hash
			outputChatBox( sha256hash ) -- Output the hash in the chat
		end
	end
)

See Also