# Austin Paolucci

## Introduction

Some of the most basic ciphers in cryptology are mono-alphabetic substitution ciphers (MASCs). This means that every use of one letter, is replaced with the same letter every time. While these ciphers can be confusing at first, they are generally not very secure, and can be cracked easily.

## Caesar Cipher

The Caesar Cipher is the most basic type of MASC. All it does, is shift the letter in the alphabet over a specific number of times for each letter. For example, if your key was 1 the plaintext: ABCD who transpose to the ciphertext: BCDE.

One way of thinking about this, is to have each letter correspond to a number, such that: A = 1 B = 2 C = 3... X = 24 Y = 25 Z = 26 (or 0)

Then, you add the key, and that the result, modulus 26.

The modulus 26 is to ensure that the result stays in the range 1 - 26.

There are only 26 possible Caesar cipher keys, since any keys greater than 25 would equal a key within the range (0 , 25).

This means that it is very easy to brute force your way to a solution if you are given cipher text, and you know a caesar cipher was used.

## Multiplicative Cipher

The Multiplicative Cipher is another basic MASC. Instead of adding the key to the plaintext, you multiply each letter by the key, and get your solution modulus 26.

For example, if your key was 7, the phrase

ABCD = <1, 2, 3, 4>

Multiplicative Key (7) * <1, 2, 3> = <7, 14, 21, 28> mod(26)

<7, 14, 21, 28> mod(26) = <7, 14, 21, 2>

<7, 14, 21, 2> = GNUB.

There is one issue with this type of cipher however, and that is that certain keys between 1 and 26 cannot be used.

This is because if the key and the number of letters (26) shares a factor, than you will end up with multiple different letters in the plaintext corresponding to the same letter in the ciphertext. This means that each letter does not have a one-to-one relationship with the cipher text, and when deciphered, the plaintext will not be accurate.

For example, if the phrase "I love discrete mathematics" was enciphered with a multiplicative key of 13, the ciphertext would be "M ZMZM ZMMMZMZM MMZZMMMZMMM", which only have two distinct letters, so it obviously cannot be transposed back to the plaintext phrase.

This means, there are only 12 possible multiplicative keys: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25.

This actually makes the cipher easy to brute force than the Caesar cipher if you already know that a multiplicative cipher was used.

## Affine Cipher

The Affine Cipher, which is the focus of this project, combines both the multiplicative and the Caesar cipher. First, multiply the letter by the multiplicative key, than you add the Caesar (or additive) key.

Assuming, like before, that letters correspond to numbers, the equation for figuring out which plaintext letter corresponds to which ciphertext letter is as follows:

```[(plaintext letter) * (multiplicative key) + (additive key)] Modulus 26
```

The same constraints as before exist for the multiplicative key, and the additive key, meaning that there are 312 (26 * 12) possible affine cipher keys.

## Software

McKenzie Ledonne and Austin Paolucci have created a piece of software that will help find the affine cipher key given some ciphertext, and a guessed crib. The software can be found on the webpage: https://austinpaolucci.github.io/Affine-Cribs/

A crib is any word you suspect will be in the ciphertext.

For example, if you knew that the encoded message would be dated, you could use the current month as a crib.

The word "the" is very commonly used as a crib, since it is one of the most frequently used word in the English language.

So, with our software, you can put cipher text into the input, and on the right side, you can put in your suspected crib next to the Search for crib button, then hit the "Search for Crib" button.

A table will then appear with the multiplicative key, the additive key, and ciphertext corresponding to the crib with that key, and the number of times that ciphertext appears. Any keys that had 0 occurrences with our ciphertext are discarded, and not shown in the table.

The key with the highest number of occurrences in the ciphertext is most likely the key, but to make sure, you can click the orange buttons in the table to try and decipher the text, and make sure it lines up.

It is important to note that these MASCS do not include any spaces, punctuation, or any character that is not a-z. It also does not care about capitalization. Letters in the output are clustered in groups of five to try and make them more readable.

If your input does include spaces, or non-alphabetic characters, they the program will automatically remove them, and make every character capitalized.

The mathematics behind finding the crib is very simple.

We just take the crib, and apply all 312 possible affine cipher keys to it. We then look in our input, and see how many times each of those occur in the ciphertext, and keep a list of it. Then we just output the information in a table.

Here is some ciphertext I generated for you to test my software:

"VBWAB GBPGQ BPSWA BNYRW BKFWL WBFRY POKBO WPSPO HLHPO BGBOS BTWNY RPYBF WLCQR FAINF WRTBR YFNOB KPHBF WRTWO LYXNR QRWDG OPERK BSPOW ABTPH HPYKB SBYFB GOPHP WBWAB JBYBO LQVBQ SLOBL YKFBT NOBWA BCQBF FRYJF PSQRC BOWDW PPNOF BQEBF LYKPN OGPFW BORWD KPPOK LRYLY KBFWL CQRFA WARFT PYFWR WNWRP YSPOW ABNYR WBKFW LWBFP SLHBO RTLRH BLYYP CPKDV RFABF HPOBW ALYRK PWALW RWALK LQQCB BYXNR TZLYK TQBLY LYKHD ABLKA LKTPH BPSSG OPGBO QDRHB LYRWV PNQKA LEBFL EBKHB LJOBL WKBLQ PSGLR YLYKO RKRTN QBAPV BEBOY BLOQD ABLKQ BFFYR TZFAP PZARF QBWWB OPGBY LYKOB LKSNO RPNFQ DVBTL YPYQD LTTBG WANYW FHBYV APFBA BLKFA LEBGL OWBKT PHGLY DVRWA WABRO CPKRB FDPNV RQQLG GOBTR LWBWA LWRWV PNQKC BRHGP FFRCQ BPWAB OVRFB SPOHB HCBOF WPGLO WRTRG LWBRY ANYWL TWRER WRBFF NTALF APOFB CLTZA BLKIN JJQRY JLYKA BLKGP QPRWR FVRWA WABJO BLWBF WOBJO BWWAB OBSPO BWALW RHNFW RYSPO HDPNW ALWDP NKPYP WSNQS RQQPN OOBXN ROBHB YWFVR WAEBO DCBFW VRFAB FFROG LWORT ZKBQL YBDGP KHPOB SNHRY JYBLO QDABL KQBFF YRTZF WNSSB KWABQ BWWBO LVLDA LQSLY RYTAP SFZRY LYKFR YBVAP QKRYJ HDYBT ZPYAL OODHP FWGBP GQBVP NQKWA RYZWA LWFJP PKLYK CBABL KBKCN WPAYP RWFYP WBYPN JASPO FROGO PGBOQ DKBTL GRWLW BKGPK HPOBY BLOQD ABLKQ BFFYR TZWPP ZFBEB OLQKB BGCOB LWAFL YKWAB YFLRK RYLSL OTLQH BOWPY BFPVA LWFCP WABOR YJDPN LYDWA RYJRT LYKPY PFLRK ALOOD YPWNY QBFFD PNZYP VVABO BVBTL YJBWF BEBYS OBBYR HCNFW VPWAP NFLYK LYKPY BFSPO PNOHL WTALJ LRYFW FQD"

For the following text, you know the word "mom" has been used. "SXGQW SOYOP GSKYX UXKYU TYTSX GQWSO YOPGS KYXUX KYUTY TSXGQ WSOYO PGSKY XUXKY UTYTS XGQWS OYOPG SKYXU XKYUT YTSXG QWQGT UQYOA YHANG FXANS QPYYJ GFXAN SQPYY JMAQG TPGTK GNYCT VLWXP ADYYJ PGTKL WXPAD YYJVU VWYCN OYOKA XLGQE FNYOP ANLCS UTASS XNUDL CSUTA SSXNU DUSSP AXPAN AYNUS SPAXN WUTKX YKUHA OAXPA SJUDK UHAOA XPASJ UDWYC ETYMU OTYXX PAJUX XJALY WXPGX UCSAV XYLAU OGJJK NYMTC DTYML GLWQG TXWYC SAASX GQWSO YOPGS KYXUX KYUTY TSPAS GJJUM GTXGT VUHAM GUXAV FYNSY JYTKS XGQWQ GTXWY CSAAW YCNAZ CSXTY XXPAK UNJFY NOAUE TYMUX OUKPX LAMNY TKLCX UOUTJ YHAMU XPSXG QWSOY OSXGQ WSOYO PGSKY XUXKY UTYTS XGQWS OYOPG SKYXU XKYUT YT"

For the following text, the word "the" is not used, but the word fish is used multiple times: "WZAXO KRHYW XOKRN ADXOK RJFEA XOKRJ FMGIX OKRJF EAXOK RWFDX OKRZA YXOKR HROKW ZARMK MFOHH FAGMN HROKW ZARMK MFOHH FAKHM NKMSY RMHMF WHWXX OKRHR ANAMN ASAKK WCAMN ANADM ZDKWC AMNAJ FEAKW CAMNA WFDMZ DKWCA MNAZA YKWCA MNAKM DMZDK WCAMN AUFMD MZDKW CAMNA BANSB ANSJM DYRSM NAHRA SKMDM ZDUFM DMZDJ MDODW ZWHIZ WYUWM KISWE NDMDK WCAMN AHROZ MZDKW CAMNA XMHHR AXMHW ZARMK MSAFF WYRMH XNWCH RANAH WRANA XNWCR ANAHW HRANA XEZZS HROZU KMNAA BANSY RANAR ANAMN AKWCA YRWFO IAHWN EZHRA SNEZX WNXEZ OZHRA RWHRW HKEZW RCAWR CSWRC AWRCS YRMHM FWHWX XEZZS HROZU KUWJS KWCAR MBAHY WXAAH MZDKW CARMB AXWEN KWCAR MBAKO VXAAH MZDKW CARMB ACWNA YRANA DWHRA SGWCA XNWCO GMZHK MSJEH OJAHH RASRM BAGWC AMFWZ UFWZU YMSYA KAAHR ACGWC AYAKA AHRAC UWKWC AMNAX MKHKW CAMNA KFWYK WCAMN AROUR KWCAM NAFWY ZWHWZ AWXHR ACOKF OIAMZ WHRAN DWZHM KIEKY RSUWM KISWE NCWHR AN"