From 01a126b3849aef4da57f1aec2793f4657203f4fb Mon Sep 17 00:00:00 2001 From: n1073645 Date: Wed, 11 Dec 2019 10:26:55 +0000 Subject: [PATCH] Added a form of scoring mechanism for entropy --- src/core/lib/Magic.mjs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/lib/Magic.mjs b/src/core/lib/Magic.mjs index b94f9c36..2de66897 100644 --- a/src/core/lib/Magic.mjs +++ b/src/core/lib/Magic.mjs @@ -307,8 +307,15 @@ class Magic { const entropyTests = OperationConfig[op.op].entropyTests; let outputEntropy = 0; if (entropyTests) { + let score = 0; outputEntropy = this.calcEntropy(new Uint8Array(output)); - if (inputEntropy < outputEntropy) + if (inputEntropy > outputEntropy) + score += 1; + if (inputEntropy > entropyTests.input[0] && inputEntropy < entropyTests.input[1]) + score += 1; + if (outputEntropy > entropyTests.output[0] && outputEntropy < entropyTests.output[1]) + score += 1; + if (!score) return; }