This is not bad at all. I'd make modest changes to the first several lines, as below.
cifrado = StringJoin[StringSplit[txt]];
largo = StringLength[cifrado];
trig = StringPartition[cifrado, 3, 1];
rep = Tally[trig];
cant = Select[rep, #[[2]] > 1 &];
posci = Position[trig, #[[1]]] & /@ cant;
dista = Flatten[Differences[#] & /@ posci];
dists = Sort[Tally[dista]]
(* Out[1008]= {{14, 1}, {42, 5}, {48, 1}, {56, 13}, {87, 1}, {98,
1}, {126, 4}, {130, 1}, {168, 3}, {196, 1}, {238, 1}, {252,
1}, {259, 2}, {266, 1}, {294, 1}, {316, 1}, {322, 1}, {376,
1}, {401, 1}, {403, 1}, {420, 1}, {479, 1}, {524, 1}, {580,
1}, {583, 1}, {714, 1}, {805, 1}} *)
From here, your use of FactorInteger
I think is good. I do not see exactly how you then deduce 14 as a candidate period, though I can think of ways that could happen, so maybe that part needs elaboration. An alternative might be to do an irregular Fourier transform.
dft[w_?NumberQ, gaps_, lens_] := Total[Exp[I*w*gaps]*lens]
Plot[Abs[dft[w, periodmults, dists[[All, 2]]]], {w, 0, 3},
PlotRange -> All, PlotPoints -> 300]
If you home in on the first two peak frequencies, you will find that they are near .454 and .898. 2*Pi/peak
gives very close to 7 and 14. Also if you clip all repeated triads that have fewer than three appearances, the signal for period 14 improves somewhat.