Core Function Hash

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Hash( <expression> ) </pre> === Description === Generate a unique hash code for a string value === Parameters === ==== expression ==== The expression to compute the ha...")
 
(Example)
Line 32: Line 32:
 
$lol = "o";
 
$lol = "o";
 
println("Hash B: " . Hash("He" . "ll" . $lol) );
 
println("Hash B: " . Hash("He" . "ll" . $lol) );
 +
</syntaxhighlight>
 +
 +
An interesting way to produce a unique Hash
 +
 +
<syntaxhighlight lang="sputnik">
 +
$UniqueID = Hash(@GUID);
 +
say $UniqueID;
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 05:49, 14 September 2013

Hash( <expression> )

Contents

Description

Generate a unique hash code for a string value

Parameters

expression

The expression to compute the hash of (this will use the string value of a given variable).

Return Value

Success: Returns a number above or below zero.

Failure: Returns 0.

Remarks

This function computes a Int64 hash to provide a bit more uniqueness than a regular Int32 hash.

Example

As you see here both strings produce the same hash yet they were constructed differently.

println("Hash A: " . Hash("Hello") );
 
$lol = "o";
println("Hash B: " . Hash("He" . "ll" . $lol) );

An interesting way to produce a unique Hash

$UniqueID = Hash(@GUID);
say $UniqueID;
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox