GT2/GT2-iOS/node_modules/crc/lib/crc1.js

22 lines
440 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
// Generated by CoffeeScript 1.9.2
var Buffer, create;
Buffer = require('buffer').Buffer;
create = require('./create');
module.exports = create('crc1', function(buf, previous) {
var accum, byte, crc, i, len;
if (!Buffer.isBuffer(buf)) {
buf = Buffer(buf);
}
crc = ~~previous;
accum = 0;
for (i = 0, len = buf.length; i < len; i++) {
byte = buf[i];
accum += byte;
}
crc += accum % 256;
return crc % 256;
});