forked from kalmar/DALGLI0
20 lines
533 B
JavaScript
20 lines
533 B
JavaScript
const crc = require("./crc.js");
|
|
const message = process.argv[3];
|
|
const flag = process.argv[2];
|
|
|
|
switch (flag) {
|
|
case '-e':
|
|
console.log(crc.encode(message).encoded);
|
|
break;
|
|
case '-d':
|
|
let fcs = JSON.parse(process.argv[4].replace(/'/g, '"'));
|
|
console.log(crc.decode(message, fcs));
|
|
break;
|
|
case '-t':
|
|
let res = crc.encode(message);
|
|
console.log(res.encoded);
|
|
console.log(crc.decode(message, res.FCS))
|
|
break;
|
|
default:
|
|
throw "incorect flag"
|
|
} |