mirror of
https://github.com/gchq/CyberChef
synced 2025-01-23 09:45:02 +00:00
Bombe: tweaks
Twiddle the default rotor sets a bit. Add a time remaining estimate for the multibombe.
This commit is contained in:
parent
49f5c94a75
commit
74eb4cca86
4 changed files with 21 additions and 15 deletions
|
@ -22,14 +22,14 @@ export const ROTORS = [
|
|||
{name: "VI", value: "JPGVOUMFYQBENHZRDKASXLICTW<AN"},
|
||||
{name: "VII", value: "NZJHGRCXMYSWBOUFAIVLPEKQDT<AN"},
|
||||
{name: "VIII", value: "FKQHTLXOCBJSPDZRAMEWNIUYGV<AN"},
|
||||
];
|
||||
|
||||
export const ROTORS_FOURTH = [
|
||||
{name: "None", value: ""},
|
||||
{name: "Beta", value: "LEYJVCNIXWPBQMDRTAKZGFUHOS"},
|
||||
{name: "Gamma", value: "FSOKANUERHMBTIYCWLQPZXVGJD"},
|
||||
];
|
||||
|
||||
export const ROTORS_OPTIONAL = [].concat(ROTORS).concat([
|
||||
{name: "None", value: ""},
|
||||
]);
|
||||
|
||||
/**
|
||||
* Provided default Enigma reflector set.
|
||||
* These are specified as 13 space-separated transposed pairs covering every letter.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import {BombeMachine} from "../lib/Bombe";
|
||||
import {ROTORS, ROTORS_OPTIONAL, REFLECTORS, Reflector} from "../lib/Enigma";
|
||||
import {ROTORS, ROTORS_FOURTH, REFLECTORS, Reflector} from "../lib/Enigma";
|
||||
|
||||
/**
|
||||
* Bombe operation
|
||||
|
@ -49,7 +49,7 @@ class Bombe extends Operation {
|
|||
{
|
||||
name: "4th (left-most, only some models) rotor",
|
||||
type: "editableOption",
|
||||
value: ROTORS_OPTIONAL,
|
||||
value: ROTORS_FOURTH,
|
||||
defaultIndex: 10
|
||||
},
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import {ROTORS, LETTERS, ROTORS_OPTIONAL, REFLECTORS, Rotor, Reflector, Plugboard, EnigmaMachine} from "../lib/Enigma";
|
||||
import {ROTORS, LETTERS, ROTORS_FOURTH, REFLECTORS, Rotor, Reflector, Plugboard, EnigmaMachine} from "../lib/Enigma";
|
||||
|
||||
/**
|
||||
* Enigma operation
|
||||
|
@ -79,8 +79,8 @@ class Enigma extends Operation {
|
|||
{
|
||||
name: "4th (left-most, only some models) rotor",
|
||||
type: "editableOption",
|
||||
value: ROTORS_OPTIONAL,
|
||||
defaultIndex: 10
|
||||
value: ROTORS_FOURTH,
|
||||
defaultIndex: 0
|
||||
},
|
||||
{
|
||||
name: "4th rotor ring setting",
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import Operation from "../Operation";
|
||||
import OperationError from "../errors/OperationError";
|
||||
import {BombeMachine} from "../lib/Bombe";
|
||||
import {ROTORS, REFLECTORS, Reflector} from "../lib/Enigma";
|
||||
import {ROTORS, ROTORS_FOURTH, REFLECTORS, Reflector} from "../lib/Enigma";
|
||||
|
||||
/**
|
||||
* Convenience method for flattening the preset ROTORS object into a newline-separated string.
|
||||
|
@ -104,11 +104,11 @@ class MultipleBombe extends Operation {
|
|||
},
|
||||
{
|
||||
name: "German Service Enigma (Third - 4 rotor)",
|
||||
value: rotorsFormat(ROTORS, 8, 9)
|
||||
value: rotorsFormat(ROTORS_FOURTH, 1, 2)
|
||||
},
|
||||
{
|
||||
name: "German Service Enigma (Fourth - 4 rotor)",
|
||||
value: rotorsFormat(ROTORS, 8, 10)
|
||||
value: rotorsFormat(ROTORS_FOURTH, 1, 3)
|
||||
},
|
||||
{
|
||||
name: "User defined",
|
||||
|
@ -178,8 +178,13 @@ class MultipleBombe extends Operation {
|
|||
* @param {number} nStops - How many stops so far
|
||||
* @param {number} progress - Progress (as a float in the range 0..1)
|
||||
*/
|
||||
updateStatus(nLoops, nStops, progress) {
|
||||
const msg = `Bombe run with ${nLoops} loops in menu (2+ desirable): ${nStops} stops, ${Math.floor(100 * progress)}% done`;
|
||||
updateStatus(nLoops, nStops, progress, start) {
|
||||
const elapsed = new Date().getTime() - start;
|
||||
const remaining = (elapsed / progress) * (1 - progress) / 1000;
|
||||
const hours = Math.floor(remaining / 3600);
|
||||
const minutes = `0${Math.floor((remaining % 3600) / 60)}`.slice(-2);
|
||||
const seconds = `0${Math.floor(remaining % 60)}`.slice(-2);
|
||||
const msg = `Bombe run with ${nLoops} loops in menu (2+ desirable): ${nStops} stops, ${Math.floor(100 * progress)}% done, ${hours}:${minutes}:${seconds} remaining`;
|
||||
self.sendStatusMessage(msg);
|
||||
}
|
||||
|
||||
|
@ -267,6 +272,7 @@ class MultipleBombe extends Operation {
|
|||
const totalRuns = choose(rotors.length, 3) * 6 * fourthRotors.length * reflectors.length;
|
||||
let nRuns = 0;
|
||||
let nStops = 0;
|
||||
const start = new Date().getTime();
|
||||
for (const rotor1 of rotors) {
|
||||
for (const rotor2 of rotors) {
|
||||
if (rotor2 === rotor1) {
|
||||
|
@ -292,7 +298,7 @@ class MultipleBombe extends Operation {
|
|||
const result = bombe.run();
|
||||
nStops += result.length;
|
||||
if (update !== undefined) {
|
||||
update(bombe.nLoops, nStops, nRuns / totalRuns);
|
||||
update(bombe.nLoops, nStops, nRuns / totalRuns, start);
|
||||
}
|
||||
if (result.length > 0) {
|
||||
msg += `\nRotors: ${runRotors.join(", ")}\nReflector: ${reflector.pairs}\n`;
|
||||
|
|
Loading…
Reference in a new issue