Change SIZE field type

This commit is contained in:
jaguarihno 2024-07-31 14:38:35 +02:00
parent a477f47aec
commit 6500d05bf3
2 changed files with 16 additions and 4 deletions

View file

@ -32,8 +32,10 @@ class BLAKE2b extends Operation {
this.args = [
{
"name": "Size",
"type": "option",
"value": ["512", "384", "256", "160", "128"]
"type": "number",
"value": 256,
"min": 8,
"max": 512
}, {
"name": "Output Encoding",
"type": "option",
@ -61,6 +63,10 @@ class BLAKE2b extends Operation {
throw new OperationError(["Key cannot be greater than 64 bytes", "It is currently " + key.length + " bytes."].join("\n"));
}
if (outSize % 8 !== 0 || outSize < 8 || outSize > 512) {
throw new OperationError("Size has to be between 8 to 512 and multiple of 8.");
}
input = new Uint8Array(input);
switch (outFormat) {
case "Hex":

View file

@ -32,8 +32,10 @@ class BLAKE2s extends Operation {
this.args = [
{
"name": "Size",
"type": "option",
"value": ["256", "160", "128"]
"type": "number",
"value": 256,
"min": 8,
"max": 256
}, {
"name": "Output Encoding",
"type": "option",
@ -62,6 +64,10 @@ class BLAKE2s extends Operation {
throw new OperationError(["Key cannot be greater than 32 bytes", "It is currently " + key.length + " bytes."].join("\n"));
}
if (outSize % 8 !== 0 || outSize < 8 || outSize > 256) {
throw new OperationError("Size has to be between 8 to 256 and multiple of 8.");
}
input = new Uint8Array(input);
switch (outFormat) {
case "Hex":