import java.util.zip.CRC32;
public class Test{
public static void main(String args[])throws Exception
{
while(true)
{
byte b[] = new byte[16];
System.out.println("Please input a String of length >=16,EXIT is\"c\"");
System.in.read(b,0,16);
String s = new String( b ).trim();
System.in.skip(System.in.available());
if(16>s.length())
{
if(s.equalsIgnoreCase("c"))
break;
System.out.print("Warning: ");
continue;
}
s = s.substring(0,6)+"-"+s.substring(6,14)+"-"+s.substring(14);
CRC32 crc32 = new CRC32();
crc32.update(s.substring(0,18).getBytes());
long l = crc32.getValue();
l = l & 65535L ^ l >> 16 & 65535L;
String temp = Long.toHexString(l);
for(int i=0;i<4-temp.length();i++)
temp = "0"+temp;
s = s+temp;
System.out.println("Serial code :"+s);
}
}
}