mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
30 lines
694 B
Java
30 lines
694 B
Java
// ======================================================================
|
|
//
|
|
// string_crc.java
|
|
//
|
|
// Copyright 2004 Sony Online Entertainment
|
|
//
|
|
// ======================================================================
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
// ======================================================================
|
|
|