Class Index | File Index

Classes


Namespace Pot.Crypt


Defined in: <potlite.js>.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Crypt and Hash utilities.
Method Summary
Method Attributes Method Name and Description
<static>  
Pot.Crypt.hashCode(data)
String hash function similar to java.lang.String.hashCode().
Namespace Detail
Pot.Crypt
Crypt and Hash utilities.
Method Detail
<static> {Function} Pot.Crypt.hashCode(data)
String hash function similar to java.lang.String.hashCode(). The hash code for a string is computed as s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], where s[i] is the ith character of the string and n is the length of the string. We mod the result to make it between 0 (inclusive) and 2^32 (exclusive).
  Pot.debug( Pot.hashCode('abc') ); // 96354
  Pot.debug( Pot.hashCode([0x61, 0x62, 0x63]) ); // 96354
Parameters:
{String|Array|*} data
A target data.
Returns:
{Number} Hash value for `string`, between 0 (inclusive) and 2^32 (exclusive). The empty string returns 0.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:35:44 GMT+0900 (JST)