mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-01-17 00:05:07 -05:00
24 lines
516 B
Java
Executable File
24 lines
516 B
Java
Executable File
// string_crc.java
|
|
|
|
package script;
|
|
|
|
// ======================================================================
|
|
|
|
public final class string_crc implements crc
|
|
{
|
|
public static int getStringCrc(String s)
|
|
{
|
|
int crc = CRC_INIT;
|
|
if (s != null)
|
|
{
|
|
char[] c = s.toCharArray();
|
|
for (int i = 0; i < c.length; ++i)
|
|
crc = crctable[((crc>>24) ^ (c[i]&0xff)) & 0xff] ^ (crc << 8);
|
|
}
|
|
return crc ^ CRC_INIT;
|
|
}
|
|
}
|
|
|
|
// ======================================================================
|
|
|