-
Notifications
You must be signed in to change notification settings - Fork 0
/
feltores_PK.txt
71 lines (53 loc) · 1.14 KB
/
feltores_PK.txt
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
StringToSequence:= func<s | [s[n]: n in [1..#s]]>;
SequenceToString:= func<q|&* q>;
StrSeq:= StringToSequence;
SeqStr:= SequenceToString;
ctextlist:=StrSeq(ctext);
mult:=[];
for char in characterset do
k:=0;
for i in ctextlist do
if i eq char then
k:=k+1;
end if;
end for;
Append(~mult,k);
end for;
parok:=[];
s:=1;
for j in mult do
Append(~parok,[j,s]);
s:=s+1;
end for;
rendezett:= Sort(parok);
kell:=[rendezett[#mult-1],rendezett[#mult]];
print kell;
gy1:=Index(characterset," ");
gy2:=Index(characterset,"e");
c:=#mult;
y1:=kell[1][2]-kell[2][2];
x1:=gy2-gy1;
print(x1);
print(y1);
a:=Solution(x1,y1,c);
print(a);
ainv0:=(Integers(74)!a)^(-1);
ainv:=(Integers()!ainv0);
print(ainv);
print(gy1);
b:= ((kell[2][2]-gy1*a) mod c);
print(b);
for i in ctextlist do
ind:=Index(characterset, i);
ujind:=((ainv*(ind-b)) mod c);
if ujind eq 0 then
uj:=characterset[c];
else
uj:=characterset[ujind];
end if;
Exclude(~ctextlist,i);
Append(~ctextlist,uj);
end for;
szoveg:=SeqStr(ctextlist);
print(szoveg);
Write("E:\\Egyetem\\Kripto\\szoveg.txt", szoveg);