mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 23:15:14 -04:00
adding prettier
This commit is contained in:
parent
c5a1b69c30
commit
ab0bc52d3c
717 changed files with 29324 additions and 18602 deletions
|
@ -8,7 +8,6 @@
|
|||
* @todo Support for UTF16
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Runs rotation operations across the input data.
|
||||
*
|
||||
|
@ -29,7 +28,6 @@ export function rot(data, amount, algo) {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotate right bitwise op.
|
||||
*
|
||||
|
@ -49,10 +47,9 @@ export function rotr(b) {
|
|||
*/
|
||||
export function rotl(b) {
|
||||
const bit = (b >> 7) & 1;
|
||||
return ((b << 1) | bit) & 0xFF;
|
||||
return ((b << 1) | bit) & 0xff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotates a byte array to the right by a specific amount as a whole, so that bits are wrapped
|
||||
* from the end of the array to the beginning.
|
||||
|
@ -70,14 +67,13 @@ export function rotrCarry(data, amount) {
|
|||
for (let i = 0; i < data.length; i++) {
|
||||
const oldByte = data[i] >>> 0;
|
||||
newByte = (oldByte >> amount) | carryBits;
|
||||
carryBits = (oldByte & (Math.pow(2, amount)-1)) << (8-amount);
|
||||
carryBits = (oldByte & (Math.pow(2, amount) - 1)) << (8 - amount);
|
||||
result.push(newByte);
|
||||
}
|
||||
result[0] |= carryBits;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rotates a byte array to the left by a specific amount as a whole, so that bits are wrapped
|
||||
* from the beginning of the array to the end.
|
||||
|
@ -92,12 +88,12 @@ export function rotlCarry(data, amount) {
|
|||
newByte;
|
||||
|
||||
amount = amount % 8;
|
||||
for (let i = data.length-1; i >= 0; i--) {
|
||||
for (let i = data.length - 1; i >= 0; i--) {
|
||||
const oldByte = data[i];
|
||||
newByte = ((oldByte << amount) | carryBits) & 0xFF;
|
||||
carryBits = (oldByte >> (8-amount)) & (Math.pow(2, amount)-1);
|
||||
result[i] = (newByte);
|
||||
newByte = ((oldByte << amount) | carryBits) & 0xff;
|
||||
carryBits = (oldByte >> (8 - amount)) & (Math.pow(2, amount) - 1);
|
||||
result[i] = newByte;
|
||||
}
|
||||
result[data.length-1] = result[data.length-1] | carryBits;
|
||||
result[data.length - 1] = result[data.length - 1] | carryBits;
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue