Remove unused StringUtils.hashString and FastMath.hash
Neither matches the client string hash; Hasher.SBStringHash does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ac5a248db
commit
99a4a6741a
2 files changed
-87
No files matched your search
@@ -583,36 +583,6 @@ final public class FastMath {
|
||||
return ret.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns a String into an Integer hash that the client will recognize.
|
||||
*
|
||||
* @param s The String to hash
|
||||
* @return the Integer hash
|
||||
*/
|
||||
public static int hash(String s) {
|
||||
int out = 0, pad = 0;
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c == ' ' || c == '\\') {
|
||||
pad += 5;
|
||||
continue;
|
||||
}
|
||||
if (c > 0x40 && c < 0x60)
|
||||
out ^= _rotl((byte) 0x60, pad);
|
||||
out ^= _rotl((byte) (c & 0xDF), pad);
|
||||
pad += 5;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for making hashes
|
||||
*/
|
||||
private static int _rotl(int value, int shift) {
|
||||
if ((shift &= 31) == 0)
|
||||
return value;
|
||||
return (value << shift) | (value >> (32 - shift));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets number of seconds until next hours
|
||||
*/
|
||||
|
||||
@@ -57,63 +57,6 @@ public class StringUtils {
|
||||
return Long.toHexString(l).toUpperCase();
|
||||
}
|
||||
|
||||
// Well done IDA Pro.
|
||||
|
||||
public static int hashString(String toHash) {
|
||||
byte[] hashArray = toHash.getBytes();
|
||||
int hash = 0;
|
||||
int shift = 0;
|
||||
if (hashArray.length == 8 || hashArray.length == 7) {
|
||||
int ecx = 0;
|
||||
if (hashArray.length == 8) {
|
||||
ecx = hashArray[7];
|
||||
}
|
||||
int eax = hashArray[4];
|
||||
int esi = ecx * 0x8;
|
||||
eax ^= esi;
|
||||
ecx ^= 0x5A0;
|
||||
esi = hashArray[5];
|
||||
eax <<= 4;
|
||||
eax ^= esi;
|
||||
esi = hashArray[6];
|
||||
eax <<= 4;
|
||||
eax ^= esi;
|
||||
esi = hashArray[2];
|
||||
eax <<= 5;
|
||||
eax ^= esi;
|
||||
esi = hashArray[1];
|
||||
int edx = hashArray[0];
|
||||
eax <<= 5;
|
||||
eax ^= esi;
|
||||
ecx /= 2;
|
||||
ecx /= 2;
|
||||
eax <<= 5;
|
||||
ecx ^= edx;
|
||||
eax ^= ecx;
|
||||
return eax;
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < hashArray.length; i++) {
|
||||
if (i == 0)
|
||||
shift = 0;
|
||||
else
|
||||
shift += 5;
|
||||
int toShift = hashArray[i] - 0x20;
|
||||
int shifted = (toShift << shift);
|
||||
hash ^= shifted;
|
||||
if (shift > 24) {
|
||||
int newShift = 0x20 - shift;
|
||||
int newShifted = toShift >> newShift;
|
||||
hash ^= newShifted;
|
||||
if (shift > 27) {
|
||||
shift -= 0x20;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
public static String wordWrap(String text, int LineWidth) {
|
||||
StringTokenizer st = new StringTokenizer(text);
|
||||
int SpaceLeft = LineWidth;
|
||||
|
||||
Reference in new issue
Block a user