diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4a96c22 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +source .venv/bin/activate \ No newline at end of file diff --git a/answers.md b/answers.md index f125e69..21a253e 100644 --- a/answers.md +++ b/answers.md @@ -3,7 +3,12 @@ ## Checkpoint 1 0. `secrets/secret0.txt` is encrypted using a Caesar Cipher. What is - its secret number? + its secret number? 78 + 'Tyger Tyger, burning bright, In the forests of the night; What imortal hand or eye, Could frame thy fearful symetry?' + + # I got some "escape sequence" warnings, plus, eventually I got a runtime error. However, I + # was able to decode by using the interactive "python" command line and typed in several lines of + # code at the >>> prompt. Once I get some feedback I'll decode more secret texts. Thank you, Stacy. 1. `secrets/secret1.txt` is encrypted using a Caesar Cipher. What is its secret number? diff --git a/caesar_cracker.py b/caesar_cracker.py new file mode 100644 index 0000000..f8bb83a --- /dev/null +++ b/caesar_cracker.py @@ -0,0 +1,64 @@ +# Nelson Mason -- LAI677LEC LOA -- 4-9-2026 + +from easybits import Bits +from collections import Counter +from ciphers.caesar import CaesarCipher + +ciphertext="ChVTanChVTaznQda]X]VnQaXVWczn8]ncWTnU^aTbcbn^UncWTn]XVWc*nFWPcnXacP[nWP]Sn^anThTzn2^d[SnUaPncWhnUTPaUd[nbhcah" + +# ChVTanChVTaznQda]X]VnQaXVWczn8]ncWTnU^aTbcbn^UncWTn]XVWc*nFWPcnX\\^acP[nWP]Sn^anThTzn2^d[SnUaP\TncWhnUTPaUd[nbh\\Tcah. + +# 8]nfWPcnSXbcP]cnSTT_bn^anbZXTb|n +# 1da]cncWTnUXaTn^UncWX]TnThTb. +# >]nfWPcnfX]VbnSPaTnWTnPb_XaT. +# FWPcncWTnWP]SznSPaTnbTXiTncWTnUXaT. + +# 0]SnfWPcnbW^d[STazntnfWPcnPacz +# 2^d[SncfXbcncWTnbX]Tfbn^UncWhnWTPac. +# 0]SnfWT]ncWhnWTPacnQTVP]nc^nQTPc| +# FWPcnSaTPSnWP]S.ntnfWPcnSaTPSnUTTc. + +# FWPcncWTnWP\\Ta.nfWPcncWTnRWPX]z +# 8]nfWPcnUda]PRTnfPbncWhnQaPX]. +# FWPcncWTnP]eX[.nfWPcnSaTPSnVaPb_| +# 3PaTnXcbnSTPS[hncTaa^abnR[Pb_. + +# FWT]ncWTnbcPabncWaTfnS^f]ncWTXanb_TPabn +# 0]SnfPcTauSnWTPeT]nfXcWncWTXancTPab) +# 3XSnWTnb\X[TnWXbnf^aZnc^nbTT. +# 3XSnWTnfW^n\PSTncWTn;P\Qn\PZTncWTT. + +# ChVTanChVTanQda]X]VnQaXVWcz +# 8]ncWTnU^aTbcbn^UncWTn]XVWc) +# FWPcnX\\^acP[nWP]Sn^anThTz +# 3PaTnUaP\TncWhnUTPaUd[nbh\\Tcah. + + + +data=Counter(ciphertext) + +keys_list = list(data.keys()) # unpack into a key list +values_list = list(data.values()) # and a values list +v=max(values_list) # get the largest value - most frequent - frequency analysis +values_list.index(v) # get the index of the largest value +idx=values_list.index(v) # put that index into a variable +key_value=keys_list[idx] # apply that same variable to the keys list + +print(keys_list) +print(values_list) +print(v) +#print(values_list.index(v)) - prints the index number +print(key_value) + +secret=Bits(str(key_value)).int - Bits(' ').int # monoalphabetic offset number + +print(secret) + +# cipher = CaesarCipher(secret) # I get a runtime error for lines 61-62. + +# print(cipher) + +# cipher.decrypt(ciphertext) +# print(cipher.decrypt(ciphertext)) + +# 'Tyger Tyger, burning bright, In the forests of the night; What imortal hand or eye, Could frame thy fearful symetry?' \ No newline at end of file