Added a form of scoring mechanism for entropy

This commit is contained in:
n1073645 2019-12-11 10:26:55 +00:00
parent d29f6efad8
commit 01a126b384

View file

@ -307,8 +307,15 @@ class Magic {
const entropyTests = OperationConfig[op.op].entropyTests; const entropyTests = OperationConfig[op.op].entropyTests;
let outputEntropy = 0; let outputEntropy = 0;
if (entropyTests) { if (entropyTests) {
let score = 0;
outputEntropy = this.calcEntropy(new Uint8Array(output)); 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; return;
} }