zjrJS.Doc.hashCode() - Beta Test Suite for zjrJS

This information lives on a webpage hosted at the following web address: 'https://www.omegajunior.net/code/zjrjs/beta.php'.

How to use zjrJS.Doc.hashCode(anyString).

Used zjrJS Version:

Stable Minified version 20141202t2322 of zjrJS.

There is no newer Beta version available.


 

Declaration
zjrJS.Doc.hashCode(String anyString);

Goal
To quickly convert any string into a hash. Based on Java's String.hashCode() via the work found here: http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/

Typical usage
Create a small identificating checksum for any string, no matter how long. The resulting hash is an integer number, save for storing in memory and databases. Not to be used for encryption. The algorithm creates a one-way hash, meaning its result cannot be converted back into its input.

Member Type
Function.

Value Type
Integer Number.

Parameters
String anyString: anything valid as a String in javascript will do.

Dependencies
zjrJS as of version 20141202t2322.

Example
<script type="text/javascript" src="zjrJS.version.js" id="zjrJS"></script>
<script type="text/javascript">/* <![CDATA[ */
var storeKey = 'filterChoice?url=' + zjrJS.Doc.hashCode(window.location),
newStoreValue = 'technology=javascript;
zjrJS.Doc.Store.set(storeKey, newStoreValue);
/* ]]> */</script>


We use this ourselves in web pages that use our zjrFacetEngine.

Download:

Download zjrJS’ latest stable build (20141202t2322) minified (7.1KB).

Download zjrJS’ latest stable build (20141202t2322) (11.9KB).