Revert "add formatter"

This reverts commit ce30989adc.
This commit is contained in:
Hare Sudhan 2024-02-25 16:23:48 -05:00
parent de3ef202d5
commit c5a1b69c30
693 changed files with 26685 additions and 51240 deletions

View file

@ -8,6 +8,7 @@
* @todo Support for UTF16
*/
/**
* Runs rotation operations across the input data.
*
@ -28,6 +29,7 @@ export function rot(data, amount, algo) {
return result;
}
/**
* Rotate right bitwise op.
*
@ -47,9 +49,10 @@ 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.
@ -67,13 +70,14 @@ 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.
@ -88,12 +92,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;
}