Add invalid key length error message

This commit is contained in:
Andy Wang 2019-10-01 22:53:50 +01:00
parent 294aa826f1
commit 458307f5ed
2 changed files with 10 additions and 2 deletions

View File

@ -70,7 +70,11 @@ class BlowfishDecrypt extends Operation {
inputType = args[3],
outputType = args[4];
if (key.length === 0) throw new OperationError("Enter a key");
if (key.length !== 8) {
throw new OperationError(`Invalid key length: ${key.length} bytes
Blowfish uses a key length of 8 bytes (64 bits).`);
}
input = Utils.convertToByteString(input, inputType);

View File

@ -70,7 +70,11 @@ class BlowfishEncrypt extends Operation {
inputType = args[3],
outputType = args[4];
if (key.length === 0) throw new OperationError("Enter a key");
if (key.length !== 8) {
throw new OperationError(`Invalid key length: ${key.length} bytes
Blowfish uses a key length of 8 bytes (64 bits).`);
}
input = Utils.convertToByteString(input, inputType);