mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 08:16:17 -04:00
Typex: add ring setting
This commit is contained in:
parent
1b1a3c261d
commit
220053c044
2 changed files with 35 additions and 11 deletions
|
@ -148,14 +148,13 @@ export class Rotor extends Enigma.Rotor {
|
|||
* @param {string} wiring - A 26 character string of the wiring order.
|
||||
* @param {string} steps - A 0..26 character string of stepping points.
|
||||
* @param {bool} reversed - Whether to reverse the rotor.
|
||||
* @param {char} ringSetting - Ring setting of the rotor.
|
||||
* @param {char} initialPosition - The initial position of the rotor.
|
||||
*/
|
||||
constructor(wiring, steps, reversed, initialPos) {
|
||||
let initialPosMod = initialPos;
|
||||
constructor(wiring, steps, reversed, ringSetting, initialPos) {
|
||||
let wiringMod = wiring;
|
||||
if (reversed) {
|
||||
initialPosMod = Enigma.i2a(Utils.mod(26 - Enigma.a2i(initialPos), 26));
|
||||
const outMap = new Array(26).fill();
|
||||
const outMap = new Array(26);
|
||||
for (let i=0; i<26; i++) {
|
||||
// wiring[i] is the original output
|
||||
// Enigma.LETTERS[i] is the original input
|
||||
|
@ -165,7 +164,7 @@ export class Rotor extends Enigma.Rotor {
|
|||
}
|
||||
wiringMod = outMap.join("");
|
||||
}
|
||||
super(wiringMod, steps, "A", initialPosMod);
|
||||
super(wiringMod, steps, ringSetting, initialPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue