Hash Code

Javascript implementation of Java’s String.hashCode() method

Skrip ini tidak untuk dipasang secara langsung. Ini adalah pustaka skrip lain untuk disertakan dengan direktif meta // @require https://update.greasyfork.org/scripts/466055/1189121/Hash%20Code.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @namespace    i2p.schimon.hashcode
// @exclude      *

// ==UserLibrary==
// @name         Hash Code
// @description  Javascript implementation of Java’s String.hashCode() method
// @author       wes (Manwe Security Consulting)
// @copyright    2010, wes
// @homepageURL  https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
// @license      MIT
// @version      1.0.0

// ==/UserScript==

// ==/UserLibrary==

// ==OpenUserJS==
// @author sjehuda
// ==/OpenUserJS==

String.prototype.hashCode = function(){
  let hash = 0;
  if (this.length == 0) return hash;
  for (let i = 0; i < this.length; i++) {
    let char = this.charCodeAt(i);
    hash = ((hash<<5)-hash)+char;
    hash = hash & hash; // Convert to 32bit integer
  }
  return hash;
};