You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

21 lines
448 B

// Generated by CoffeeScript 1.7.1
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;
});