Here you can find the source of calculateHash(String str)
Parameter | Description |
---|---|
str | String to hash. |
static public String calculateHash(String str)
//package com.java2s; /**//from ww w . j a v a 2 s . c o m * Copyright © 2008-2012 NetAllied Systems GmbH, Ravensburg, Germany. * * Licensed under the MIT Open Source License, * for details please see LICENSE file or the website * http://www.opensource.org/licenses/mit-license.php */ public class Main { /** * Calculates Hash. * * @param str * String to hash. * @return hash. */ static public String calculateHash(String str) { long h = 0; long g; int pos = 0; while (pos < str.length()) { h = (h << 4) + str.charAt(pos++); if ((g = (h & 0xf0000000)) != 0) h ^= g >> 24; h &= ~g; } return String.valueOf(h); } }