aboutsummaryrefslogtreecommitdiff
path: root/node_modules/crc/lib/crc16_xmodem.js
diff options
context:
space:
mode:
authorHumairAK <humair88@hotmail.com>2016-07-21 06:24:24 +0000
committerHumairAK <humair88@hotmail.com>2016-07-21 06:24:24 +0000
commit2549ee68e435b77e7e07d3ea95363268cbfe9164 (patch)
tree8f48f6447a4377f1bc15ae7d73dbab3337044720 /node_modules/crc/lib/crc16_xmodem.js
parentd694c1a73f77def42c17b58027f046bf9e1af809 (diff)
Added other dependencies for authentication, made minor adjustments to index.js, added templating for exams, will remove dependencie modules later, keep for now
Diffstat (limited to 'node_modules/crc/lib/crc16_xmodem.js')
-rw-r--r--node_modules/crc/lib/crc16_xmodem.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/node_modules/crc/lib/crc16_xmodem.js b/node_modules/crc/lib/crc16_xmodem.js
new file mode 100644
index 0000000..2bc58a6
--- /dev/null
+++ b/node_modules/crc/lib/crc16_xmodem.js
@@ -0,0 +1,31 @@
+'use strict';
+
+var _buffer = require('buffer');
+
+var _define_crc = require('./define_crc');
+
+var _define_crc2 = _interopRequireDefault(_define_crc);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = (0, _define_crc2.default)('xmodem', function (buf, previous) {
+ if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _buffer.Buffer)(buf);
+
+ var crc = typeof previous !== 'undefined' ? ~ ~previous : 0x0;
+
+ for (var index = 0; index < buf.length; index++) {
+ var byte = buf[index];
+ var code = crc >>> 8 & 0xFF;
+
+ code ^= byte & 0xFF;
+ code ^= code >>> 4;
+ crc = crc << 8 & 0xFFFF;
+ crc ^= code;
+ code = code << 5 & 0xFFFF;
+ crc ^= code;
+ code = code << 7 & 0xFFFF;
+ crc ^= code;
+ }
+
+ return crc;
+}); \ No newline at end of file