mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 15:07:11 -04:00
ran the linter
This commit is contained in:
parent
44cf916f43
commit
b842a38c84
2 changed files with 34 additions and 20 deletions
|
@ -9,6 +9,11 @@
|
|||
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
/**
|
||||
* Function to take the user input and encode using the given arguments
|
||||
* @param input string of binary
|
||||
* @param args array
|
||||
*/
|
||||
export function calculateParityBit(input, args) {
|
||||
let count1s = 0;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
|
@ -31,7 +36,11 @@ export function calculateParityBit(input, args) {
|
|||
}
|
||||
}
|
||||
|
||||
// just removes the parity bit to return the original data
|
||||
/**
|
||||
* just removes the parity bit to return the original data
|
||||
* @param input string of binary, encoded
|
||||
* @param args array
|
||||
*/
|
||||
export function decodeParityBit(input, args) {
|
||||
if (args[1] === "End") {
|
||||
return input.slice(0, -1);
|
||||
|
|
|
@ -66,13 +66,18 @@ class ParityBit extends Operation {
|
|||
if (input.length === 0) {
|
||||
return input;
|
||||
}
|
||||
/**
|
||||
* determines weather to use the encode or decode method based off args[2]
|
||||
* @param input input to be encoded or decoded
|
||||
* @param args array
|
||||
*/
|
||||
const method = (input, args) => args[2] === "Encode" ? calculateParityBit(input, args) : decodeParityBit(input, args);
|
||||
if (args[3].length > 0) {
|
||||
let byteStrings = input.split(args[3]);
|
||||
const byteStrings = input.split(args[3]);
|
||||
for (let byteStringsArrayIndex = 0; byteStringsArrayIndex < byteStrings.length; byteStringsArrayIndex++) {
|
||||
byteStrings[byteStringsArrayIndex] = method(byteStrings[byteStringsArrayIndex], args);
|
||||
}
|
||||
return byteStrings.join(args[3])
|
||||
return byteStrings.join(args[3]);
|
||||
}
|
||||
return method(input, args);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue