Message Boards Message Boards

2
|
10199 Views
|
6 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Vigenère cipher/Cryptanalysis

Posted 9 years ago

Trying to understand more of the functions in Mathematica related to operations on text, I am trying to solve the following, I have obtained from :

Vigenère cipher/Cryptanalysis

This is what I have done in an attempt to resolve this problem:

text = "MOMUD EKAPV TQEFM OEVHP AJMII CDCTI FGYAG JSPXY ALUYM NSMYH
  VUXJE LEPXJ FXGCM JHKDZ RYICU HYPUS PGIGM OIYHF WHTCQ KMLRD
  ITLXZ LJFVQ GHOLW CUHLO MDSOE KTALU VYLNZ RFGBX PHVGA LWQIS
  FGRPH JOOFW GUBYI LAPLA LCAFA AMKLG CETDW VOELJ IKGJB XPHVG
  ALWQC SNWBU BYHCU HKOCE XJEYK BQKVY KIIEH GRLGH XEOLW AWFOJ
  ILOVV RHPKD WIHKN ATUHN VRYAQ DIVHX FHRZV QWMWV LGSHN NLVZS
  JLAKI FHXUF XJLXM TBLQV RXXHR FZXGV LRAJI EXPRV OSMNP KEPDT
  LPRWM JAZPK LQUZA ALGZX GVLKL GJTUI ITDSU REZXJ ERXZS HMPST
  MTEOE PAPJH SMFNB YVQUZ AALGA YDNMP AQOWT UHDBV TSMUE UIMVH
  QGVRW AEFSP EMPVE PKXZY WLKJA GWALT VYYOB YIXOK IHPDS EVLEV
  RVSGB JOGYW FHKBL GLXYA MVKIS KIEHY IMAPX UOISK PVAGN MZHPW
  TTZPV XFCCD TUHJH WLAPF YULTB UXJLN SIJVV YOVDJ SOLXG TGRVO
  SFRII CTMKO JFCQF KTINQ BWVHG TENLH HOGCS PSFPV GJOKM SIFPR
  ZPAAS ATPTZ FTPPD PORRF TAXZP KALQA WMIUD BWNCT LEFKO ZQDLX
  BUXJL ASIMR PNMBF ZCYLV WAPVF QRHZV ZGZEF KBYIO OFXYE VOWGB
  BXVCB XBAWG LQKCM ICRRX MACUO IKHQU AJEGL OIJHH XPVZW JEWBA
  FWAML ZZRXJ EKAHV FASMU LVVUT TGK";

We erased the spaces of the variable txt

junto = StringJoin[StringSplit[text]];
largo = StringLength[junto];
freq = Table[
   StringCount[junto, StringTake[junto, {i, i + 2}]], {i, 1, 826}];
    Tally[DeleteCases[freq, 1]]

I have done so we are looking for the position of the trigrams used within the text,

StringTake[junto, {#, # + 2}] & /@ Flatten[Position[freq, 4]]

DeleteDuplicates[
 StringTake[junto, {#, # + 2}] & /@ Flatten[Position[freq, 3]]]

Calcualte prb for use later

prb = StringPosition[junto, #] & /@ {"UXJ", "CUH", "BYI", "TUH", 
   "XJL"}

for example we calculate the differences of prb, to know the distances between each repetition of a Trigrama.

DeleteDuplicates[Flatten[Differences[#, {1, 0}] & /@ prb]]

Here decompose each number into its prime factors to try to find the possible differente in the key of the cipher text is clearly seen that the numbers that most times are repeated are the 2 and 7, i thought that the key could be 7,but i have not received anything in particular

Tally[Flatten[#[[;; , 1]] & /@ 
   FactorInteger[{524, 126, 42, 98, 322, 252, 168, 266}]]]

Perhaps a different approach can help me

Any help is welcome, thaks in advance.

POSTED BY: Luis Ledesma
6 Replies

I added an example showing one way to attack this cipher in ResourceFunction["IrregularPeriodogram"].

[I realize this is years after the fact.]

POSTED BY: Daniel Lichtblau

And other functions who might be useful are:

ResourceFunction["VigenereDecipher"]
ResourceFunction["VigenereCipher"]

(and yes, years after the fact as well)

POSTED BY: Sander Huisman

Sander, does all this necromancy make us, umm, "visionaires"?

POSTED BY: Daniel Lichtblau

I guess so :-) !

POSTED BY: Sander Huisman

Your position differences for the four times repeated trigram "XJE" are all divisible by 14. All but one difference for the thrice-repeated trigrams is divisible by 14. I think I would assume that one was an accidental repeat (due to actually different plain text trigrams getting the same encoding). So expect a key length of 7 or 14 because 2 is too short. Also there is no reason to ignore the doubly-repeated cases, and they might give similar information (I have not checked).

POSTED BY: Daniel Lichtblau
Posted 9 years ago

Does any literature that i recommend? Or something that can help me solve this problem, because it took several attempts and i have not been able to resolve, i've noticed the closer look at the page that i shared that the key is

:THECHESHIRECAT

but I still don't know how get it using Mathematica,greetings to all..

POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract