fork(8) download
  1. class crc
  2. {
  3. public static int get_CRC(byte[] buf)
  4. {
  5. int crc = 0;
  6. int i;
  7. for (int index = 0; index != buf.length; ++index) {
  8. for (i = 0x80; i != 0; i >>>= 1) {
  9. if ((crc & 0x8000) != 0) {
  10. crc <<= 1;
  11. crc ^= 0x1021;
  12. } else {
  13. crc <<= 1;
  14. }
  15. if ((buf[index] & i) != 0) {
  16. crc ^= 0x1021;
  17. }
  18. }
  19. }
  20. return crc;
  21. }
  22. public static void main(String[] args)
  23. {
  24. byte[] buf = {0x31, 0x14, 0x15, (byte)0x92, 0x66};
  25. System.out.println(get_CRC(buf));
  26. }
  27. }
Success #stdin #stdout 0.03s 711168KB
stdin
Standard input is empty
stdout
1905634707