2022-03-17 12:08:49 -04:00
|
|
|
|
#define ALPHABET_SIZE 26
|
|
|
|
|
#define WHEELS_AMOUNT 3
|
|
|
|
|
|
2022-03-17 12:27:47 -04:00
|
|
|
|
struct Key
|
|
|
|
|
{
|
|
|
|
|
String hex; // HEX представление символа
|
|
|
|
|
String view; // его удобочитаемая форма
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-17 08:38:01 -04:00
|
|
|
|
// Латинский алфавит в HEX представлении
|
2022-03-17 12:27:47 -04:00
|
|
|
|
const Key key_values[ALPHABET_SIZE] =
|
2022-03-17 08:38:01 -04:00
|
|
|
|
{
|
2022-03-17 12:27:47 -04:00
|
|
|
|
{"51", "q"}, // Code51 - q
|
|
|
|
|
{"57", "w"}, // Code57 - w
|
|
|
|
|
{"45", "e"}, // Code45 - e
|
|
|
|
|
{"52", "r"}, // Code52 - r
|
|
|
|
|
{"54", "t"}, // Code54 - t
|
|
|
|
|
{"59", "y"}, // Code59 - y
|
|
|
|
|
{"55", "u"}, // Code55 - u
|
|
|
|
|
{"49", "i"}, // Code49 - i
|
2022-03-17 16:24:56 -04:00
|
|
|
|
{"4f", "o"}, // Code4F - o
|
2022-03-17 12:27:47 -04:00
|
|
|
|
{"50", "p"}, // Code50 - p
|
|
|
|
|
{"41", "a"}, // Code41 - a
|
|
|
|
|
{"53", "s"}, // Code53 - s
|
|
|
|
|
{"44", "d"}, // Code44 - d
|
|
|
|
|
{"46", "f"}, // Code46 - f
|
|
|
|
|
{"47", "g"}, // Code47 - g
|
|
|
|
|
{"48", "h"}, // Code48 - h
|
2022-03-17 16:24:56 -04:00
|
|
|
|
{"4a", "j"}, // Code4A - j
|
|
|
|
|
{"4b", "k"}, // Code4B - k
|
|
|
|
|
{"4c", "l"}, // Code4C - l
|
|
|
|
|
{"5z", "z"}, // Code5A - z
|
2022-03-17 12:27:47 -04:00
|
|
|
|
{"58", "x"}, // Code58 - x
|
|
|
|
|
{"43", "c"}, // Code43 - c
|
|
|
|
|
{"56", "v"}, // Code56 - v
|
|
|
|
|
{"42", "b"}, // Code42 - b
|
2022-03-17 16:24:56 -04:00
|
|
|
|
{"4e", "n"}, // Code4E - n
|
|
|
|
|
{"4d", "m"} // Code4D - m
|
2022-03-17 08:38:01 -04:00
|
|
|
|
};
|
|
|
|
|
|
2022-03-22 07:58:12 -04:00
|
|
|
|
// Сдвиг в алфавите для каждого из "дисков"
|
|
|
|
|
// относительно их нормального состояния
|
2022-03-17 16:24:56 -04:00
|
|
|
|
size_t key_shifts[WHEELS_AMOUNT] =
|
2022-03-17 08:38:01 -04:00
|
|
|
|
{
|
2022-03-17 16:24:56 -04:00
|
|
|
|
3,
|
2022-03-17 08:38:01 -04:00
|
|
|
|
1,
|
2022-03-17 16:24:56 -04:00
|
|
|
|
2
|
2022-03-22 07:58:12 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Mutation
|
|
|
|
|
{
|
|
|
|
|
size_t from = 0;
|
|
|
|
|
size_t to = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const Mutation mutations[WHEELS_AMOUNT + 1][ALPHABET_SIZE] =
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
{0, 15 },
|
|
|
|
|
{1, 4 },
|
|
|
|
|
{2, 25 },
|
|
|
|
|
{3, 20 },
|
|
|
|
|
{4, 14 },
|
|
|
|
|
{5, 7 },
|
|
|
|
|
{6, 23 },
|
|
|
|
|
{7, 18 },
|
|
|
|
|
{8, 2 },
|
|
|
|
|
{9, 21 },
|
|
|
|
|
{10, 5 },
|
|
|
|
|
{11, 12 },
|
|
|
|
|
{12, 19 },
|
|
|
|
|
{13, 1 },
|
|
|
|
|
{14, 6 },
|
|
|
|
|
{15, 11 },
|
|
|
|
|
{16, 17 },
|
|
|
|
|
{17, 8 },
|
|
|
|
|
{18, 13 },
|
|
|
|
|
{19, 16 },
|
|
|
|
|
{20, 9 },
|
|
|
|
|
{21, 22 },
|
|
|
|
|
{22, 0 },
|
|
|
|
|
{23, 24 },
|
|
|
|
|
{24, 3 },
|
|
|
|
|
{25, 10 }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{0, 25 },
|
|
|
|
|
{1, 14 },
|
|
|
|
|
{2, 20 },
|
|
|
|
|
{3, 4 },
|
|
|
|
|
{4, 18 },
|
|
|
|
|
{5, 24 },
|
|
|
|
|
{6, 3 },
|
|
|
|
|
{7, 10 },
|
|
|
|
|
{8, 5 },
|
|
|
|
|
{9, 22 },
|
|
|
|
|
{10, 15 },
|
|
|
|
|
{11, 2 },
|
|
|
|
|
{12, 8 },
|
|
|
|
|
{13, 16 },
|
|
|
|
|
{14, 23 },
|
|
|
|
|
{15, 7 },
|
|
|
|
|
{16, 12 },
|
|
|
|
|
{17, 21 },
|
|
|
|
|
{18, 1 },
|
|
|
|
|
{19, 11 },
|
|
|
|
|
{20, 6 },
|
|
|
|
|
{21, 13 },
|
|
|
|
|
{22, 9 },
|
|
|
|
|
{23, 17 },
|
|
|
|
|
{24, 0 },
|
|
|
|
|
{25, 19 }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{0, 4 },
|
|
|
|
|
{1, 7 },
|
|
|
|
|
{2, 17 },
|
|
|
|
|
{3, 21 },
|
|
|
|
|
{4, 23 },
|
|
|
|
|
{5, 6 },
|
|
|
|
|
{6, 0 },
|
|
|
|
|
{7, 14 },
|
|
|
|
|
{8, 1 },
|
|
|
|
|
{9, 16 },
|
|
|
|
|
{10, 20 },
|
|
|
|
|
{11, 18 },
|
|
|
|
|
{12, 8 },
|
|
|
|
|
{13, 12 },
|
|
|
|
|
{14, 25 },
|
|
|
|
|
{15, 5 },
|
|
|
|
|
{16, 11 },
|
|
|
|
|
{17, 24 },
|
|
|
|
|
{18, 13 },
|
|
|
|
|
{19, 22 },
|
|
|
|
|
{20, 10 },
|
|
|
|
|
{21, 19 },
|
|
|
|
|
{22, 15 },
|
|
|
|
|
{23, 3 },
|
|
|
|
|
{24, 9 },
|
|
|
|
|
{25, 2 }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
{0, 21},
|
|
|
|
|
{1, 10},
|
|
|
|
|
{2, 22},
|
|
|
|
|
{3, 17},
|
|
|
|
|
{4, 6},
|
|
|
|
|
{5, 8},
|
|
|
|
|
{6, 4},
|
|
|
|
|
{7, 19},
|
|
|
|
|
{8, 5},
|
|
|
|
|
{9, 25},
|
|
|
|
|
{10, 1},
|
|
|
|
|
{11, 20},
|
|
|
|
|
{12, 18},
|
|
|
|
|
{13, 15},
|
|
|
|
|
{14, 16},
|
|
|
|
|
{15, 13},
|
|
|
|
|
{16, 14},
|
|
|
|
|
{17, 3},
|
|
|
|
|
{18, 12},
|
|
|
|
|
{19, 7},
|
|
|
|
|
{20, 11},
|
|
|
|
|
{21, 0},
|
|
|
|
|
{22, 2},
|
|
|
|
|
{23, 24},
|
|
|
|
|
{24, 23},
|
|
|
|
|
{25, 9}
|
|
|
|
|
}
|
2022-03-17 08:38:01 -04:00
|
|
|
|
};
|