Squirrel/Server/Functions/Hashing/SHA1

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with '{{Squirrel/Title|SHA1}} {{RequiresModule|lu_hashing|Modules/Squirrel/lu_hashing}} This function returns an SHA-1 hash value of the given string. This is useful for example when s…')
 
(Example)
 
Line 13: Line 13:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
+
<code lang="squirrel">
 +
function onPlayerCommand( pPlayer, szCommand, szText )
 +
{
 +
if ( szCommand == "sha1" )
 +
{
 +
if ( szText ) MessagePlayer( "The SHA1 of " + szText + " is " + SHA1( szText ), pPlayer );
 +
}
 +
 +
return 1;
 +
}
 +
</code>
  
 
=== Notes ===
 
=== Notes ===
  
Write example notes here
+
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}}

Latest revision as of 15:47, 29 September 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
Note: This function requires the external module lu_hashing.

This function returns an SHA-1 hash value of the given string. This is useful for example when storing account passwords.

[edit] Syntax

  1. string SHA1( string text )

[edit] Arguments

  • text - The string to be hashed

[edit] Example

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "sha1" )
  5. {
  6. if ( szText ) MessagePlayer( "The SHA1 of " + szText + " is " + SHA1( szText ), pPlayer );
  7. }
  8. return 1;
  9. }
  10.  

[edit] Notes

The function MessagePlayer and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

[edit] Related Functions

These functions are provided by the official module lu_hashing.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox