2018-05-23 19:59:57 +02:00
|
|
|
/**
|
|
|
|
* @author n1474335 [n1474335@gmail.com]
|
|
|
|
* @copyright Crown Copyright 2016
|
|
|
|
* @license Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Operation from "../Operation";
|
|
|
|
import Utils from "../Utils";
|
|
|
|
import { bitOp, add } from "../lib/BitwiseOp";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ADD operation
|
|
|
|
*/
|
|
|
|
class ADD extends Operation {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ADD constructor
|
|
|
|
*/
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
|
|
|
this.name = "ADD";
|
|
|
|
this.module = "Default";
|
|
|
|
this.description = "ADD the input with the given key (e.g. <code>fe023da5</code>), MOD 255";
|
|
|
|
this.inputType = "byteArray";
|
|
|
|
this.outputType = "byteArray";
|
|
|
|
this.args = [
|
|
|
|
{
|
|
|
|
"name": "Key",
|
|
|
|
"type": "toggleString",
|
|
|
|
"value": "",
|
2018-08-19 23:50:49 +02:00
|
|
|
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
|
2018-05-23 19:59:57 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {byteArray} input
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {byteArray}
|
|
|
|
*/
|
|
|
|
run(input, args) {
|
|
|
|
const key = Utils.convertToByteArray(args[0].string || "", args[0].option);
|
|
|
|
|
|
|
|
return bitOp(input, key, add);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight ADD
|
|
|
|
*
|
|
|
|
* @param {Object[]} pos
|
|
|
|
* @param {number} pos[].start
|
|
|
|
* @param {number} pos[].end
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {Object[]} pos
|
|
|
|
*/
|
|
|
|
highlight(pos, args) {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlight ADD in reverse
|
|
|
|
*
|
|
|
|
* @param {Object[]} pos
|
|
|
|
* @param {number} pos[].start
|
|
|
|
* @param {number} pos[].end
|
|
|
|
* @param {Object[]} args
|
|
|
|
* @returns {Object[]} pos
|
|
|
|
*/
|
|
|
|
highlightReverse(pos, args) {
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ADD;
|