weikemu.js 306 B

1234567891011121314151617
  1. function CRC(dataBuf){
  2. var temp = 0;
  3. var crc = 0xffff;
  4. for(var i=0; i<dataBuf.length; i++){
  5. crc ^= parseInt(dataBuf[i].toString());
  6. for (var j=0; j<8; j++){
  7. temp = 1 & crc;
  8. crc >>= 1;
  9. if (temp == 1){
  10. crc ^= 0xa001;
  11. }
  12. }
  13. }
  14. crc ^= 0xffff;
  15. crc = ('0000'+crc.toString(16)).substr(-4);
  16. return crc;
  17. }