mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 06:01:02 +01:00
Merge branch 'master' of https://github.com/LukeSerne/CyberChef
This commit is contained in:
commit
1078c37043
@ -44,8 +44,8 @@ class Substitute extends Operation {
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const plaintext = Utils.expandAlphRange(args[0]).join(""),
|
||||
ciphertext = Utils.expandAlphRange(args[1]).join("");
|
||||
const plaintext = Utils.expandAlphRange([...args[0]]),
|
||||
ciphertext = Utils.expandAlphRange([...args[1]]);
|
||||
let output = "",
|
||||
index = -1;
|
||||
|
||||
@ -53,9 +53,9 @@ class Substitute extends Operation {
|
||||
output = "Warning: Plaintext and Ciphertext lengths differ\n\n";
|
||||
}
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
index = plaintext.indexOf(input[i]);
|
||||
output += index > -1 && index < ciphertext.length ? ciphertext[index] : input[i];
|
||||
for (const character of input) {
|
||||
index = plaintext.indexOf(character);
|
||||
output += index > -1 && index < ciphertext.length ? ciphertext[index] : character;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
Loading…
Reference in New Issue
Block a user