Here you can find the source of hash(String str, int offset)
Parameter | Description |
---|---|
str | String to be hashed. |
offset | Offset in the decryption buffer. |
public static long hash(String str, int offset)
//package com.java2s; /**/*from w ww.ja v a 2 s . c o m*/ * OpenTeufel: A role playing game * (MPQParser: MPQ parsing library for Java(R)) * * (C) Copyright 2014-2014 Christian <horschi[at]gmail.com> * (C) Copyright 2010-2010 Michael Seifert <michael.seifert[at]gmx.net> * * This file was part of MPQParser and has been adjusted to fit into OpenTeufel. * * OpenTeufel is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenTeufel is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenTeufel. If not, see <http://www.gnu.org/licenses/>. */ public class Main { private final static long MASK_INT = 0xFFFFFFFFL; private final static long[] stormBuffer = new long[0x500]; /** * Creates the hash of the specified string with the specified offset. * * @param str * String to be hashed. * @param offset * Offset in the decryption buffer. * @return Hashed string. */ public static long hash(String str, int offset) { long seed1 = 0x7FED7FEDL; long seed2 = 0xEEEEEEEEL; for (char c : str.toCharArray()) { long ch = Character.toUpperCase(c); seed1 = stormBuffer[(int) (offset + ch)] ^ (seed1 + seed2); seed1 = seed1 & MASK_INT; long seed12 = (seed1 + seed2) & MASK_INT; long seed2Shifted = (seed2 << 5) & MASK_INT; seed2 = (ch + seed12 + seed2Shifted + 3) & MASK_INT; } return seed1 & MASK_INT; } }