mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 00:05:11 -04:00
Added the ability to do circular left shifts
This commit is contained in:
parent
c9d9730726
commit
e2f369fb4d
1 changed files with 17 additions and 4 deletions
|
@ -28,6 +28,11 @@ class BitShiftLeft extends Operation {
|
||||||
"name": "Amount",
|
"name": "Amount",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"value": 1
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Circular",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -38,13 +43,21 @@ class BitShiftLeft extends Operation {
|
||||||
* @returns {ArrayBuffer}
|
* @returns {ArrayBuffer}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const amount = args[0];
|
const amount = args[0],
|
||||||
|
circular = args[1];
|
||||||
|
|
||||||
input = new Uint8Array(input);
|
input = new Uint8Array(input);
|
||||||
|
|
||||||
|
if (circular) {
|
||||||
|
return input.map(b => {
|
||||||
|
return (b << amount) | b >> (8 - amount);
|
||||||
|
}).buffer;
|
||||||
|
} else {
|
||||||
return input.map(b => {
|
return input.map(b => {
|
||||||
return (b << amount) & 0xff;
|
return (b << amount) & 0xff;
|
||||||
}).buffer;
|
}).buffer;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight Bit shift left
|
* Highlight Bit shift left
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue