ESM: Tidied up recently ported ops

This commit is contained in:
n1474335 2018-05-27 16:13:18 +01:00
parent 905bc6699e
commit 6768038a2f
14 changed files with 47 additions and 27 deletions

View file

@ -6,6 +6,7 @@
import Operation from "../Operation";
import Utils from "../Utils";
import OperationError from "../errors/OperationError";
import forge from "node-forge/dist/forge.min.js";
/**
@ -66,10 +67,10 @@ class DESDecrypt extends Operation {
[,, mode, inputType, outputType] = args;
if (key.length !== 8) {
return `Invalid key length: ${key.length} bytes
throw new OperationError(`Invalid key length: ${key.length} bytes
DES uses a key length of 8 bytes (64 bits).
Triple DES uses a key length of 24 bytes (192 bits).`;
Triple DES uses a key length of 24 bytes (192 bits).`);
}
input = Utils.convertToByteString(input, inputType);
@ -82,7 +83,7 @@ Triple DES uses a key length of 24 bytes (192 bits).`;
if (result) {
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
} else {
return "Unable to decrypt input with these parameters.";
throw new OperationError("Unable to decrypt input with these parameters.");
}
}