mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-16 08:58:30 +01:00
76 lines
1.5 KiB
JavaScript
76 lines
1.5 KiB
JavaScript
|
/**
|
||
|
* @author n1474335 [n1474335@gmail.com]
|
||
|
* @copyright Crown Copyright 2016
|
||
|
* @license Apache-2.0
|
||
|
*/
|
||
|
|
||
|
import Operation from "../Operation";
|
||
|
|
||
|
/**
|
||
|
* Bit shift left operation
|
||
|
*/
|
||
|
class BitShiftLeft extends Operation {
|
||
|
|
||
|
/**
|
||
|
* BitShiftLeft constructor
|
||
|
*/
|
||
|
constructor() {
|
||
|
super();
|
||
|
|
||
|
this.name = "Bit shift left";
|
||
|
this.module = "Default";
|
||
|
this.description = "Shifts the bits in each byte towards the left by the specified amount.";
|
||
|
this.inputType = "byteArray";
|
||
|
this.outputType = "byteArray";
|
||
|
this.args = [
|
||
|
{
|
||
|
"name": "Amount",
|
||
|
"type": "number",
|
||
|
"value": 1
|
||
|
}
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {byteArray} input
|
||
|
* @param {Object[]} args
|
||
|
* @returns {byteArray}
|
||
|
*/
|
||
|
run(input, args) {
|
||
|
const amount = args[0];
|
||
|
|
||
|
return input.map(b => {
|
||
|
return (b << amount) & 0xff;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Highlight Bit shift left
|
||
|
*
|
||
|
* @param {Object[]} pos
|
||
|
* @param {number} pos[].start
|
||
|
* @param {number} pos[].end
|
||
|
* @param {Object[]} args
|
||
|
* @returns {Object[]} pos
|
||
|
*/
|
||
|
highlight(pos, args) {
|
||
|
return pos;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Highlight Bit shift left 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 BitShiftLeft;
|