Site Tools


hash_32bit
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


hash_32bit [2007/03/02 02:32] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +# $EPIC: hash_32bit.txt,v 1.3 2007/03/02 02:32:04 jnelson Exp $
 +======Synopsis:======
 +$__hash_32bit__(<word> <length>)
 +
 +======Technical:======
 +   * The <word> and <length> arguments are [[what is a word|dwords]], which is different from most function arguments.
 +   * If the <word> argument is omitted the empty string is returned
 +   * If the <length> argument is omitted it defaults to 0
 +   * If the <length> argument is a negative number of is greater than 64, it is changed to 20.
 +   * The return value of this function is a 32 bit signed integer that is a "hash" of the first <length> characters in <word>.
 +   * Analytically speaking, hashing is a specific type of lossy compression.
 +   * All lossy compression techniques suffer from "collisions" A collision occurs when two different <word>s yield the same return value.  If you must avoid collisions, use $[[encode]]() instead.
 +   * The inverse of this principle is that all lossy compression techniques are irreversible.  You cannot take the return value of this function and determine what <word> was.  If you must be able to recreate <word>, use $[[encode]]() instead.
 +   * The return value of this function is deterministic within the lifetime of the client.  The algorithm used to compute this value is subject to change in the future; you should not "save" the return value of this function to a file for use in future versions in epic.
 +
 +======Practical:======
 +You can use $__hash_32bit__() to convert an arbitrary string (perhaps
 +containing characters that cannot be used in alias names) into a 32 bit signed
 +integer value which you can use as part of an alias name. Collisions will
 +occur.  You cannot recover the original <word> from the output of this
 +function.  Please keep these in mind when using this function.
 +
 +======Returns:======
 +A 32 bit signed integer (it can be either negative or positive) that 
 +is deterministically derived from the first <length> characters in <word>.
 +
 +======Examples:======
 +$hash_32bit("hello there") returns 51439
  
hash_32bit.txt · Last modified: 2007/03/02 02:32 by 127.0.0.1