mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 16:51:31 -04:00
Corrected padding and added error cases
This commit is contained in:
parent
2b39684904
commit
ce638de9b1
1 changed files with 7 additions and 1 deletions
|
@ -48,10 +48,16 @@ class RailFenceCypherDecode extends Operation {
|
|||
|
||||
let cipher = input;
|
||||
|
||||
if (key < 2) {
|
||||
return "Key has to be bigger than 2";
|
||||
} else if (key > cipher.length) {
|
||||
return "Key should be smaller than the cipher's length";
|
||||
}
|
||||
|
||||
const rest = cipher.length % key;
|
||||
|
||||
if (rest !== 0) {
|
||||
cipher = cipher + (" ".repeat(rest));
|
||||
cipher = cipher + (" ".repeat(key-rest));
|
||||
}
|
||||
|
||||
const blockLen = cipher.length / key;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue