diff --git a/src/node/config/excludedOperations.mjs b/src/node/config/excludedOperations.mjs
index 89c3a820..441a36d9 100644
--- a/src/node/config/excludedOperations.mjs
+++ b/src/node/config/excludedOperations.mjs
@@ -18,4 +18,8 @@ export default [
"Untar",
"Unzip",
"Zip",
+
+ // Also uses files
+ "DetectFileType",
+ "ExtractEXIF",
];
diff --git a/test/tests/assertionHandler.mjs b/test/tests/assertionHandler.mjs
index b51896cf..bf3da89c 100644
--- a/test/tests/assertionHandler.mjs
+++ b/test/tests/assertionHandler.mjs
@@ -52,7 +52,7 @@ const wrapRun = (run) => () => {
*/
export function it(name, run) {
return {
- name,
+ name: `Node API: ${name}`,
run: wrapRun(run),
};
}
diff --git a/test/tests/nodeApi/ops.mjs b/test/tests/nodeApi/ops.mjs
index e66f4109..7054ddc2 100644
--- a/test/tests/nodeApi/ops.mjs
+++ b/test/tests/nodeApi/ops.mjs
@@ -17,7 +17,6 @@ import assert from "assert";
import it from "../assertionHandler";
import {
- ADD,
addLineNumbers,
adler32Checksum,
AESDecrypt,
@@ -30,12 +29,13 @@ import {
toBase64,
toHex,
} from "../../../src/node/index";
+import chef from "../../../src/node/index";
import TestRegister from "../../TestRegister";
TestRegister.addApiTests([
it("ADD: toggleString argument", () => {
- const result = ADD("sample input", {
+ const result = chef.ADD("sample input", {
key: {
string: "some key",
option: "Hex"
@@ -85,6 +85,63 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "weiy qtpsh");
}),
+ it("analyzeHash", () => {
+ const result = chef.analyseHash(chef.MD5("some input"));
+ const expected = `Hash length: 32
+Byte length: 16
+Bit length: 128
+
+Based on the length, this hash could have been generated by one of the following hashing functions:
+MD5
+MD4
+MD2
+HAVAL-128
+RIPEMD-128
+Snefru
+Tiger-128`;
+ assert.strictEqual(result.toString(), expected);
+ }),
+
+ it("AND", () => {
+ const result = chef.AND("Scot-free", {
+ key: "Raining Cats and Dogs",
+ });
+ assert.strictEqual(result.toString(), ".\"M$(D E.");
+ }),
+
+ it("atBash Cipher", () => {
+ const result = chef.atbashCipher("Happy as a Clam");
+ assert.strictEqual(result.toString(), "Szkkb zh z Xozn");
+ }),
+
+ it("Bcrypt", () => {
+ const result = chef.bcrypt("Put a Sock In It");
+ assert.strictEqual(result.toString(), "$2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6");
+ }),
+
+ it("bcryptCompare", () => {
+ const result = chef.bcryptCompare("Put a Sock In It", {
+ hash: "$2a$10$2rT4a3XnIecBsd1H33dMTuyYE1HJ1n9F.V2rjQtAH73rh1qvOf/ae",
+ });
+ assert.strictEqual(result.toString(), "Match: Put a Sock In It");
+ }),
+
+ it("Bcrypt Parse", () => {
+ const result = chef.bcryptParse("$2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6");
+ const expected = `Rounds: 10
+Salt: $2a$10$ODeP1.6fMsb.ENk2ngPUCO
+Password hash: 7qTGVPyHA9TqDVcyupyed8FjsiF65L6
+Full hash: $2a$10$ODeP1.6fMsb.ENk2ngPUCO7qTGVPyHA9TqDVcyupyed8FjsiF65L6`;
+ assert.strictEqual(result.toString(), expected);
+ }),
+
+ it("bifid cipher decode", () => {
+ const result = chef.bifidCipherDecode("Vhef Qnte Ke Xfhz Mxon Bmgf", {
+ keyword: "Alpha",
+ });
+ assert.strictEqual(result.toString(), "What Goes Up Must Come Down");
+ }),
+
it("bifid cipher encode: string option", () => {
const result = bifidCipherEncode("some input", {
keyword: "mykeyword",
@@ -92,6 +149,11 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "nmhs zmsdo");
}),
+ it("bit shift left", () => {
+ const result = chef.bitShiftLeft("Keep Your Eyes Peeled");
+ assert.strictEqual(result.toString(), ".ÊÊà@²Þêä@.òÊæ@ ÊÊØÊÈ");
+ }),
+
it("bitShiftRight: number and option", () => {
const result = bitShiftRight("some bits to shift", {
type: "Arithmetic shift",
@@ -100,6 +162,49 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "9762\u001014:9\u0010:7\u00109443:");
}),
+ it("Blowfish encrypt", () => {
+ const result = chef.blowfishEncrypt("Fool's Gold", {
+ key: {
+ string: "One",
+ option: "hex",
+ },
+ iv: {
+ string: "Two",
+ option: "utf8"
+ }
+ });
+ assert.strictEqual(result.toString(), "8999b513bf2ff064b2977dea7e05f1b5");
+ }),
+
+ it("Blowfish decrypt", () => {
+ const result = chef.blowfishDecrypt("8999b513bf2ff064b2977dea7e05f1b5", {
+ key: {
+ string: "One",
+ option: "hex",
+ },
+ iv: {
+ string: "Two",
+ option: "utf8",
+ }
+ });
+ assert.strictEqual(result.toString(), "Fool's Gold");
+ }),
+
+ it("BSON Deserialise", () => {
+ const result = chef.BSONDeserialise("....phrase.....Mouth-watering..");
+ assert.strictEqual(result.toString(), "{\"phrase\": \"Mouth-watering\"}");
+ }),
+
+ it("BSON Serialise", () => {
+ const result = chef.BSONSerialise({"phrase": "Mouth-watering"});
+ assert.strictEqual(result.toString(), " ....phrase.....Mouth-watering..");
+ }),
+
+ it("Bzip2 Decompress", () => {
+ const result = chef.bzip2Decompress(chef.fromBase64("QlpoOTFBWSZTWUdQlt0AAAIVgEAAAQAmJAwAIAAxBkxA0A2pTL6U2CozxdyRThQkEdQlt0A="));
+ assert.strictEqual(result.toString(), "Fit as a Fiddle");
+ }),
+
it("cartesianProduct: binary string", () => {
const result = cartesianProduct("1:2\\n\\n3:4", {
itemDelimiter: ":",
@@ -107,6 +212,99 @@ TestRegister.addApiTests([
assert.strictEqual(result.toString(), "(1,3):(1,4):(2,3):(2,4)");
}),
+ it("Change IP format", () => {
+ const result = chef.changeIPFormat("172.20.23.54", {
+ inputFormat: "Dotted Decimal",
+ outputFormat: "Hex",
+ });
+ assert.strictEqual(result.toString(), "ac141736");
+ }),
+
+ it("Chi square", () => {
+ const result = chef.chiSquare("Burst Your Bubble");
+ assert.strictEqual(result.toString(), "433.55399816176475");
+ }),
+
+ it("Compare CTPH Hashes", () => {
+ const result = chef.compareCTPHHashes("1234\n3456");
+ assert.strictEqual(result.toString(), "0");
+ }),
+
+ it("Compare SSDEEPHashes", () => {
+ const result = chef.compareCTPHHashes("1234\n3456");
+ assert.strictEqual(result.toString(), "0");
+ }),
+
+ it("Convert area", () => {
+ const result = chef.convertArea("12345", {
+ inputUnits: "Square metre (sq m)",
+ outputUnits: "Isle of Wight"
+ });
+ assert.strictEqual(result.toString(), "0.00003248684210526316");
+ }),
+
+ it("Convert data units", () => {
+ const result = chef.convertDataUnits("12345", {
+ inputUnits: "Bits (b)",
+ outputUnits: "Kilobytes (KB)",
+ });
+ assert.strictEqual(result.toString(), "1.543125");
+ }),
+
+ it("Convert distance", () => {
+ const result = chef.convertDistance("1234567", {
+ inputUnits: "Nanometres (nm)",
+ outputUnits: "Furlongs (fur)",
+ });
+ assert.strictEqual(result.toString(), "0.00000613699494949495");
+ }),
+
+ it("Convert mass", () => {
+ const result = chef.convertMass("123", {
+ inputUnits: "Earth mass (M⊕)",
+ outputUnits: "Great Pyramid of Giza (6,000,000 tonnes)",
+ });
+ assert.strictEqual(result.toString(), "122429895000000000");
+ }),
+
+ it("Convert speed", () => {
+ const result = chef.convertSpeed("123", {
+ inputUnits: "Lunar escape velocity",
+ outputUnits: "Jet airliner cruising speed",
+ });
+ assert.strictEqual(result.toString(), "1168.5");
+ }),
+
+ it("Count occurrences", () => {
+ const result = chef.countOccurrences("Talk the Talk", {
+ searchString: {
+ string: "Tal",
+ option: "Simple string",
+ }
+ });
+ assert.strictEqual(result.toString(), "2");
+ }),
+
+ it("CRC16 Checksum", () => {
+ const result = chef.CRC16Checksum("Rain on Your Parade");
+ assert.strictEqual(result.toString(), "db1c");
+ }),
+
+ it("CRC32 Checksum", () => {
+ const result = chef.CRC32Checksum("Rain on Your Parade");
+ assert.strictEqual(result.toString(), "e902f76c");
+ }),
+
+ it("CSS Beautify", () => {
+ const result = chef.CSSBeautify("header {color:black;padding:3rem;}");
+ const expected = `header {
+\\tcolor:black;
+\\tpadding:3rem;
+}
+`;
+ assert.strictEqual(result.toString(), expected);
+ }),
+
it("CSS minify: boolean", () => {
const input = `header {
// comment
@@ -119,6 +317,242 @@ color: white;
assert.strictEqual(result.toString(), "header {// comment width: 100%;color: white;}");
}),
+ it("CSS Selector", () => {
+ const result = chef.CSSSelector("Hello