Tidied up Bacon Cipher operations
This commit is contained in:
parent
f0b3bd0ede
commit
b31f32a7e7
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Bacon resources.
|
||||
* Bacon Cipher resources.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
@ -33,12 +33,12 @@ export const BACON_TRANSLATIONS_FOR_ENCODING = [
|
||||
BACON_TRANSLATION_AB
|
||||
];
|
||||
export const BACON_CLEARER_MAP = {
|
||||
[BACON_TRANSLATIONS[0]]: /[^01]/g,
|
||||
[BACON_TRANSLATIONS[1]]: /[^ABab]/g,
|
||||
[BACON_TRANSLATIONS[2]]: /[^A-Za-z]/g,
|
||||
[BACON_TRANSLATION_01]: /[^01]/g,
|
||||
[BACON_TRANSLATION_AB]: /[^ABab]/g,
|
||||
[BACON_TRANSLATION_CASE]: /[^A-Za-z]/g,
|
||||
};
|
||||
export const BACON_NORMALIZE_MAP = {
|
||||
[BACON_TRANSLATIONS[1]]: {
|
||||
[BACON_TRANSLATION_AB]: {
|
||||
"A": "0",
|
||||
"B": "1",
|
||||
"a": "0",
|
||||
|
@ -1,10 +1,8 @@
|
||||
/**
|
||||
* BaconCipher operation.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import {
|
||||
@ -14,19 +12,19 @@ import {
|
||||
} from "../lib/Bacon";
|
||||
|
||||
/**
|
||||
* BaconCipherDecode operation
|
||||
*/
|
||||
* Bacon Cipher Decode operation
|
||||
*/
|
||||
class BaconCipherDecode extends Operation {
|
||||
/**
|
||||
* BaconCipherDecode constructor
|
||||
*/
|
||||
* BaconCipherDecode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Bacon Cipher Decode";
|
||||
this.module = "Default";
|
||||
this.description = "Bacon's cipher or the Baconian cipher is a method of steganography(a method of hiding a secret message as opposed to just a cipher) devised by Francis Bacon in 1605.[1][2][3] A message is concealed in the presentation of text, rather than its content.";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/Bacon%27s_cipher";
|
||||
this.description = "Bacon's cipher or the Baconian cipher is a method of steganography devised by Francis Bacon in 1605. A message is concealed in the presentation of text, rather than its content.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Bacon%27s_cipher";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
@ -49,10 +47,10 @@ class BaconCipherDecode extends Operation {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} input
|
||||
* @param {Object[]} args
|
||||
* @returns {String}
|
||||
*/
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [alphabet, translation, invert] = args;
|
||||
const alphabetObject = BACON_ALPHABETS[alphabet];
|
||||
@ -97,8 +95,8 @@ class BaconCipherDecode extends Operation {
|
||||
const inputArray = input.match(/(.{5})/g) || [];
|
||||
|
||||
let output = "";
|
||||
for (let index = 0; index < inputArray.length; index++) {
|
||||
const code = inputArray[index];
|
||||
for (let i = 0; i < inputArray.length; i++) {
|
||||
const code = inputArray[i];
|
||||
const number = parseInt(code, 2);
|
||||
output += number < alphabetObject.alphabet.length ? alphabetObject.alphabet[number] : "?";
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
/**
|
||||
* BaconCipher operation.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import {
|
||||
@ -14,19 +12,19 @@ import {
|
||||
} from "../lib/Bacon";
|
||||
|
||||
/**
|
||||
* BaconCipherEncode operation
|
||||
*/
|
||||
* Bacon Cipher Encode operation
|
||||
*/
|
||||
class BaconCipherEncode extends Operation {
|
||||
/**
|
||||
* BaconCipherEncode constructor
|
||||
*/
|
||||
* BaconCipherEncode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Bacon Cipher Encode";
|
||||
this.module = "Default";
|
||||
this.description = "Bacon's cipher or the Baconian cipher is a method of steganography(a method of hiding a secret message as opposed to just a cipher) devised by Francis Bacon in 1605.[1][2][3] A message is concealed in the presentation of text, rather than its content.";
|
||||
this.infoURL = "https://en.wikipedia.org/wiki/Bacon%27s_cipher";
|
||||
this.description = "Bacon's cipher or the Baconian cipher is a method of steganography devised by Francis Bacon in 1605. A message is concealed in the presentation of text, rather than its content.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Bacon%27s_cipher";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
@ -54,10 +52,10 @@ class BaconCipherEncode extends Operation {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {String} input
|
||||
* @param {Object[]} args
|
||||
* @returns {String}
|
||||
*/
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const [alphabet, translation, keep, invert] = args;
|
||||
|
||||
|
@ -14,89 +14,89 @@
|
||||
import {
|
||||
setLongTestFailure,
|
||||
logTestReport,
|
||||
} from "../lib/utils";
|
||||
} from "../lib/utils.mjs";
|
||||
|
||||
import TestRegister from "../lib/TestRegister.mjs";
|
||||
import "./tests/BCD";
|
||||
import "./tests/BSON";
|
||||
import "./tests/BaconCipher";
|
||||
import "./tests/Base58";
|
||||
import "./tests/Base64";
|
||||
import "./tests/Base62";
|
||||
import "./tests/BitwiseOp";
|
||||
import "./tests/ByteRepr";
|
||||
import "./tests/CartesianProduct";
|
||||
import "./tests/CharEnc";
|
||||
import "./tests/ChangeIPFormat";
|
||||
import "./tests/Charts";
|
||||
import "./tests/Checksum";
|
||||
import "./tests/Ciphers";
|
||||
import "./tests/Code";
|
||||
import "./tests/Comment";
|
||||
import "./tests/Compress";
|
||||
import "./tests/ConditionalJump";
|
||||
import "./tests/Crypt";
|
||||
import "./tests/CSV";
|
||||
import "./tests/DateTime";
|
||||
import "./tests/ExtractEmailAddresses";
|
||||
import "./tests/Fork";
|
||||
import "./tests/FromDecimal";
|
||||
import "./tests/Hash";
|
||||
import "./tests/HaversineDistance";
|
||||
import "./tests/Hexdump";
|
||||
import "./tests/Image";
|
||||
import "./tests/IndexOfCoincidence";
|
||||
import "./tests/Jump";
|
||||
import "./tests/JSONBeautify";
|
||||
import "./tests/JSONMinify";
|
||||
import "./tests/JSONtoCSV";
|
||||
import "./tests/JWTDecode";
|
||||
import "./tests/JWTSign";
|
||||
import "./tests/JWTVerify";
|
||||
import "./tests/MS";
|
||||
import "./tests/Magic";
|
||||
import "./tests/MorseCode";
|
||||
import "./tests/NetBIOS";
|
||||
import "./tests/OTP";
|
||||
import "./tests/PGP";
|
||||
import "./tests/PHP";
|
||||
import "./tests/ParseIPRange";
|
||||
import "./tests/ParseQRCode";
|
||||
import "./tests/PowerSet";
|
||||
import "./tests/Regex";
|
||||
import "./tests/Register";
|
||||
import "./tests/RemoveDiacritics";
|
||||
import "./tests/Rotate";
|
||||
import "./tests/SeqUtils";
|
||||
import "./tests/SetDifference";
|
||||
import "./tests/SetIntersection";
|
||||
import "./tests/SetUnion";
|
||||
import "./tests/StrUtils";
|
||||
import "./tests/SymmetricDifference";
|
||||
import "./tests/TextEncodingBruteForce";
|
||||
import "./tests/TranslateDateTimeFormat";
|
||||
import "./tests/Magic";
|
||||
import "./tests/ParseTLV";
|
||||
import "./tests/Media";
|
||||
import "./tests/ToFromInsensitiveRegex";
|
||||
import "./tests/BCD.mjs";
|
||||
import "./tests/BSON.mjs";
|
||||
import "./tests/BaconCipher.mjs";
|
||||
import "./tests/Base58.mjs";
|
||||
import "./tests/Base64.mjs";
|
||||
import "./tests/Base62.mjs";
|
||||
import "./tests/BitwiseOp.mjs";
|
||||
import "./tests/ByteRepr.mjs";
|
||||
import "./tests/CartesianProduct.mjs";
|
||||
import "./tests/CharEnc.mjs";
|
||||
import "./tests/ChangeIPFormat.mjs";
|
||||
import "./tests/Charts.mjs";
|
||||
import "./tests/Checksum.mjs";
|
||||
import "./tests/Ciphers.mjs";
|
||||
import "./tests/Code.mjs";
|
||||
import "./tests/Comment.mjs";
|
||||
import "./tests/Compress.mjs";
|
||||
import "./tests/ConditionalJump.mjs";
|
||||
import "./tests/Crypt.mjs";
|
||||
import "./tests/CSV.mjs";
|
||||
import "./tests/DateTime.mjs";
|
||||
import "./tests/ExtractEmailAddresses.mjs";
|
||||
import "./tests/Fork.mjs";
|
||||
import "./tests/FromDecimal.mjs";
|
||||
import "./tests/Hash.mjs";
|
||||
import "./tests/HaversineDistance.mjs";
|
||||
import "./tests/Hexdump.mjs";
|
||||
import "./tests/Image.mjs";
|
||||
import "./tests/IndexOfCoincidence.mjs";
|
||||
import "./tests/Jump.mjs";
|
||||
import "./tests/JSONBeautify.mjs";
|
||||
import "./tests/JSONMinify.mjs";
|
||||
import "./tests/JSONtoCSV.mjs";
|
||||
import "./tests/JWTDecode.mjs";
|
||||
import "./tests/JWTSign.mjs";
|
||||
import "./tests/JWTVerify.mjs";
|
||||
import "./tests/MS.mjs";
|
||||
import "./tests/Magic.mjs";
|
||||
import "./tests/MorseCode.mjs";
|
||||
import "./tests/NetBIOS.mjs";
|
||||
import "./tests/OTP.mjs";
|
||||
import "./tests/PGP.mjs";
|
||||
import "./tests/PHP.mjs";
|
||||
import "./tests/ParseIPRange.mjs";
|
||||
import "./tests/ParseQRCode.mjs";
|
||||
import "./tests/PowerSet.mjs";
|
||||
import "./tests/Regex.mjs";
|
||||
import "./tests/Register.mjs";
|
||||
import "./tests/RemoveDiacritics.mjs";
|
||||
import "./tests/Rotate.mjs";
|
||||
import "./tests/SeqUtils.mjs";
|
||||
import "./tests/SetDifference.mjs";
|
||||
import "./tests/SetIntersection.mjs";
|
||||
import "./tests/SetUnion.mjs";
|
||||
import "./tests/StrUtils.mjs";
|
||||
import "./tests/SymmetricDifference.mjs";
|
||||
import "./tests/TextEncodingBruteForce.mjs";
|
||||
import "./tests/TranslateDateTimeFormat.mjs";
|
||||
import "./tests/Magic.mjs";
|
||||
import "./tests/ParseTLV.mjs";
|
||||
import "./tests/Media.mjs";
|
||||
import "./tests/ToFromInsensitiveRegex.mjs";
|
||||
import "./tests/YARA.mjs";
|
||||
import "./tests/ConvertCoordinateFormat";
|
||||
import "./tests/Enigma";
|
||||
import "./tests/Bombe";
|
||||
import "./tests/MultipleBombe";
|
||||
import "./tests/Typex";
|
||||
import "./tests/BLAKE2b";
|
||||
import "./tests/BLAKE2s";
|
||||
import "./tests/Protobuf";
|
||||
import "./tests/ParseSSHHostKey";
|
||||
import "./tests/DefangIP";
|
||||
import "./tests/ParseUDP";
|
||||
import "./tests/ConvertCoordinateFormat.mjs";
|
||||
import "./tests/Enigma.mjs";
|
||||
import "./tests/Bombe.mjs";
|
||||
import "./tests/MultipleBombe.mjs";
|
||||
import "./tests/Typex.mjs";
|
||||
import "./tests/BLAKE2b.mjs";
|
||||
import "./tests/BLAKE2s.mjs";
|
||||
import "./tests/Protobuf.mjs";
|
||||
import "./tests/ParseSSHHostKey.mjs";
|
||||
import "./tests/DefangIP.mjs";
|
||||
import "./tests/ParseUDP.mjs";
|
||||
|
||||
// Cannot test operations that use the File type yet
|
||||
//import "./tests/SplitColourChannels";
|
||||
// import "./tests/SplitColourChannels.mjs";
|
||||
|
||||
// import "./tests/nodeApi/nodeApi";
|
||||
// import "./tests/nodeApi/ops";
|
||||
// import "./tests/nodeApi/nodeApi.mjs";
|
||||
// import "./tests/nodeApi/ops.mjs";
|
||||
|
||||
const testStatus = {
|
||||
allTestsPassing: true,
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
* BaconCipher tests.
|
||||
* Bacon Cipher tests.
|
||||
*
|
||||
* @author Karsten Silkenbäumer [github.com/kassi]
|
||||
* @copyright Karsten Silkenbäumer 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../TestRegister";
|
||||
import TestRegister from "../../lib/TestRegister";
|
||||
import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon";
|
||||
|
||||
const alphabets = Object.keys(BACON_ALPHABETS);
|
||||
@ -242,9 +242,7 @@ TestRegister.addTests([
|
||||
args: [alphabets[1], translations[3], true]
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
||||
TestRegister.addTests([
|
||||
},
|
||||
{
|
||||
name: "Bacon Encode: no input",
|
||||
input: "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user