-
Notifications
You must be signed in to change notification settings - Fork 586
/
non-exact-subbreak2.cpp
46 lines (34 loc) · 1.07 KB
/
non-exact-subbreak2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*! \file non-exact-subbreak2.cpp
* \brief New attempt at breaking non-exact substitution cipher
* \author Georgi Gerganov
*/
#include "subbreak2.h"
int main(int argc, char ** argv) {
printf("Usage: %s n-gram.txt\n", argv[0]);
if (argc < 2) {
return -1;
}
srand(time(0));
Cipher::TParameters params;
Cipher::TFreqMap freqMap;
if (Cipher::loadFreqMap(argv[1], freqMap) == false) {
return -1;
}
std::string plain;
plain = R"(
As far as services go, only two steady contributors of revenue
streams keep swelling without Apple having to charge
subscription fees. One is the money paid by Google parent Alphabet
for searches made through Apple products such as the Safari browser and Siri.
)";
TClusters enc;
Cipher::encryptExact(params, plain, enc);
params.maxClusters = 27;
for (auto & c : enc) {
params.maxClusters = std::max(params.maxClusters, c + 1);
}
Cipher::TResult result;
Cipher::subbreak(params, freqMap, result);
Cipher::printText(enc, result.clMap);
return 0;
}