socketioMEANseed/server/node_modules/crc/lib/crc.js
server/node_modules/crc/lib/crc.jsRaw
1// Generated by CoffeeScript 1.7.1
2var CRC, hex;
3
4hex = require('./hex');
5
6module.exports = CRC = (function() {
7 CRC.prototype.INIT_CRC = 0x00;
8
9 CRC.prototype.XOR_MASK = 0x00;
10
11 CRC.prototype.WIDTH = 0;
12
13 CRC.prototype.pack = function(crc) {
14 return '';
15 };
16
17 CRC.prototype.each_byte = function(buf, cb) {
18 var i, _i, _ref, _results;
19 if (!Buffer.isBuffer(buf)) {
20 buf = Buffer(buf);
21 }
22 _results = [];
23 for (i = _i = 0, _ref = buf.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
24 _results.push(cb(buf[i]));
25 }
26 return _results;
27 };
28
29 function CRC() {
30 this.crc = this.INIT_CRC;
31 }
32
33 CRC.prototype.digest_length = function() {
34 return Math.ceil(this.WIDTH / 8.0);
35 };
36
37 CRC.prototype.update = function(data) {};
38
39 CRC.prototype.reset = function() {
40 return this.crc = this.INIT_CRC;
41 };
42
43 CRC.prototype.checksum = function(signed) {
44 var sum;
45 if (signed == null) {
46 signed = true;
47 }
48 sum = this.crc ^ this.XOR_MASK;
49 if (signed) {
50 sum = sum >>> 0;
51 }
52 return sum;
53 };
54
55 CRC.prototype.finish = function() {
56 return this.pack(this.checksum());
57 };
58
59 CRC.prototype.hexdigest = function(value) {
60 var result;
61 if (value != null) {
62 this.update(value);
63 }
64 result = this.finish();
65 this.reset();
66 return result;
67 };
68
69 return CRC;
70
71})();