path
stringlengths 9
117
| type
stringclasses 2
values | project
stringclasses 10
values | commit_hash
stringlengths 40
40
| commit_message
stringlengths 1
137
| ground_truth
stringlengths 0
2.74k
| main_code
stringlengths 102
3.37k
| context
stringlengths 0
14.7k
|
---|---|---|---|---|---|---|---|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decryptMessage
|
Modified
|
Ciphey~Ciphey
|
0fcb8c744315fe2da9c375da9522fe74a7be7f38
|
Transposition cipher is now implemented but doesn't decrypt
|
<0>:<del> # The transposition decrypt function will simulate the "columns" and
<1>:<del> # "rows" of the grid that the plaintext is written on by using a list
<2>:<del> # of strings. First, we need to calculate a few values.
<3>:<del>
<4>:<del> # The number of "columns" in our transposition grid:
<5>:<add> numOfColumns = int(math.ceil(len(message) / float(key)))
<del> numOfColumns = math.ceil(len(message) / key)
<6>:<del> # The number of "rows" in our grid will need:
<7>:<add> numOfRows = key
<del> numOfRows = key
<8>:<del> # The number of "shaded boxes" in the last "column" of the grid:
<9>:<add> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<del> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<10>:<del>
<11>:<del> # Each string in plaintext represents a column in the grid.
<12>:<add> plaintext = [""] * numOfColumns
<del> plaintext = [""] * numOfColumns
<13>:<del>
<14>:<del> # The col and row variables point to where in the grid the next
<15>:<del> # character in the encrypted message will go.
<16>:<add> column = 0
<del> col = 0
<17>:<add> row = 0
<del> row = 0
<18>:<del>
<19>:<add> for symbol in message:
<del> for symbol in message:
<20>:<add> plaintext[column] += symbol
<del> plaintext[col] += symbol
<21>:<add> column += 1 # Point to the next column.
<del> col += 1 # point to next column
<22>:<del>
<23>:<del> # If there are no more columns OR we're at a shaded box, go back to
<24>:<del> # the first column and the next row.
<25>:<del> if (col == numOfColumns) or (
<26>:<del> col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
<27>:<del> ):
<28>:<del> col = 0
<29>:<del> row += 1
<30>:<del>
<31>:<del> return "".join(plaintext)
|
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decryptMessage(self, key, message):
<0> # The transposition decrypt function will simulate the "columns" and
<1> # "rows" of the grid that the plaintext is written on by using a list
<2> # of strings. First, we need to calculate a few values.
<3>
<4> # The number of "columns" in our transposition grid:
<5> numOfColumns = math.ceil(len(message) / key)
<6> # The number of "rows" in our grid will need:
<7> numOfRows = key
<8> # The number of "shaded boxes" in the last "column" of the grid:
<9> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<10>
<11> # Each string in plaintext represents a column in the grid.
<12> plaintext = [""] * numOfColumns
<13>
<14> # The col and row variables point to where in the grid the next
<15> # character in the encrypted message will go.
<16> col = 0
<17> row = 0
<18>
<19> for symbol in message:
<20> plaintext[col] += symbol
<21> col += 1 # point to next column
<22>
<23> # If there are no more columns OR we're at a shaded box, go back to
<24> # the first column and the next row.
<25> if (col == numOfColumns) or (
<26> col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
<27> ):
<28> col = 0
<29> row += 1
<30>
<31> return "".join(plaintext)
<32>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition
Transposition(lc)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
main()
main(self)
hackTransposition(self, message)
hackTransposition(message)
at: math
ceil(x: SupportsFloat, /) -> int
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def hackTransposition(self, message):
- print("Hacking...")
-
- # Python programs can be stopped at any time by pressing Ctrl-C (on
- # Windows) or Ctrl-D (on Mac and Linux)
-
- # brute-force by looping through every possible key
+ # we could probably multi thread this
+ for key in range(1, len(message)):
- for key in range(1, len(message)):
-
+ decryptedText = self.decryptMessage(key, message)
- decryptedText = self.decryptMessage(key, message)
-
- # if self.lc.checkLanguage(decryptedText):
- # Check with user to see if the decrypted key has been found.
+ # if decrypted text is english, return true
+ if self.lc.checkLanguage(decryptedText):
- if self.lc.checkLanguage(decryptedText):
+ print("found decrypted text")
+ return {
- return {
+ "lc": self.lc,
- "lc": self.lc,
+ "IsPlaintext?": True,
- "IsPlaintext?": True,
+ "Plaintext": decryptedText,
- "Plaintext": decryptedText,
+ "Cipher": "Transposition",
- "Cipher": "Transposition",
+ "Extra Information": f"The key is {key}",
- "Extra Information": f"The key is {key}",
+ }
- }
+ # after all keys, return false
+ print("no decrypted text")
+ return {
- return {
+ "lc": self.lc,
- "lc": self.lc,
+ "IsPlaintext?": False,
- "IsPlaintext?": False,
+ "Plaintext": None,
- "Plaintext": None,
+ "</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def hackTransposition(self, message):
# offset: 1
<s>Plaintext?": False,
+ "Plaintext": None,
- "Plaintext": None,
+ "Cipher": "Transposition",
- "Cipher": "Transposition",
+ "Extra Information": None,
- "Extra Information": None,
+ }
- }
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def main(self):
+ # this main exists so i can test it
+ myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
- myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
-
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
-
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
-
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
-
- ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
-
- rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
-
- meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
-
- ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
-
- BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSser</s>
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def main(self):
# offset: 1
<s>lmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-
- -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
- hackedMessage = self.hackTransposition(myMessage)
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decrypt(self, text):
+ # Brute-force by looping through every possible key.
- # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ return decryptedText
- decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
===========changed ref 5===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def getName(self):
+ return "Transposition"
+
===========changed ref 6===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 7===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ if __name__ == "__main__":
+ t = Transposition("a")
+ t.main()
+
===========changed ref 8===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
+
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.__init__
|
Modified
|
Ciphey~Ciphey
|
0fcb8c744315fe2da9c375da9522fe74a7be7f38
|
Transposition cipher is now implemented but doesn't decrypt
|
<5>:<add> self.trans = tr.Transposition(self.lc)
<del> # self.trans = Transposition(self.lc)
<7>:<add> self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
<del> self.list_of_objects = [self.caesar, self.reverse, self.pig]
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.caesar = ca.Caesar(self.lc)
<2> self.reverse = re.Reverse(self.lc)
<3> self.viginere = vi.Viginere(self.lc)
<4> self.pig = pi.PigLatin(self.lc)
<5> # self.trans = Transposition(self.lc)
<6>
<7> self.list_of_objects = [self.caesar, self.reverse, self.pig]
<8>
|
===========changed ref 0===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def getName(self):
+ return "Transposition"
+
===========changed ref 1===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 2===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ if __name__ == "__main__":
+ t = Transposition("a")
+ t.main()
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
+
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
+ """
+ ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
+ ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝
+ ██║ ██║██████╔╝███████║█████╗ ╚████╔╝
+ ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝
+ ╚██████�</s>
===========changed ref 5===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
# offset: 1
<s>╝
+ ╚██████╗██║██║ ██║ ██║███████╗ ██║
+ © Brandon Skerritt
+ https://github.com/brandonskerritt/ciphey
+ """
try:
import Decryptor.basicEncryption.caesar as ca
import Decryptor.basicEncryption.reverse as re
import Decryptor.basicEncryption.viginere as vi
import Decryptor.basicEncryption.pigLatin as pi
+ import Decryptor.basicEncryption.transposition as tr
except ModuleNotFoundError:
import ciphey.Decryptor.basicEncryption.caesar as ca
import ciphey.Decryptor.basicEncryption.reverse as re
import ciphey.Decryptor.basicEncryption.viginere as vi
import ciphey.Decryptor.basicEncryption.pigLatin as pi
+ import ciphey.Decryptor.basicEncryption.transposition as tr
"""
So I want to assign the prob distribution to objects
so it makes sense to do this?
list of objects
for each item in the prob distribution
replace that with the appropriate object in the list?
So each object has a getName func that returns the name as a str
new_prob_dict = {}
for key, val in self.prob:
for obj in list:
if obj.getName() == key:
new_prob_dict[obj] = val
But I don't need to do all this,</s>
===========changed ref 6===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
# offset: 2
<s>?
The dict comes in already sorted.
So why do I need the probability values if it's sorted?
It'd be easier if I make a list in the same order as the dict?
sooo
list_objs = [caeser, etc]
counter = 0
for key, val in self.prob:
for listCounter, item in enumerate(list_objs):
if item.getName() == key:
# moves the item
list_objs.insert(counter, list_objs.pop(listCounter))
counter = counter + 1
Eventually we get a sorted list of obj
"""
===========changed ref 7===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decrypt(self, text):
+ # Brute-force by looping through every possible key.
- # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ return decryptedText
- decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
===========changed ref 8===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def hackTransposition(self, message):
+ print("Hacking...")
+
+ # Python programs can be stopped at any time by pressing Ctrl-C (on
+ # Windows) or Ctrl-D (on Mac and Linux)
+
+ # brute-force by looping through every possible key
+ for key in range(1, len(message)):
+
+ decryptedText = self.decryptMessage(key, message)
+
+ # if self.lc.checkLanguage(decryptedText):
+ # Check with user to see if the decrypted key has been found.
+ if self.lc.checkLanguage(decryptedText):
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": True,
+ "Plaintext": decryptedText,
+ "Cipher": "Transposition",
+ "Extra Information": f"The key is {key}",
+ }
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": False,
+ "Plaintext": None,
+ "Cipher": "Transposition",
+ "Extra Information": None,
+ }
+
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
0fcb8c744315fe2da9c375da9522fe74a7be7f38
|
Transposition cipher is now implemented but doesn't decrypt
|
<11>:<add> print(answer)
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def decrypt(self, text):
<0> self.text = text
<1> from multiprocessing.dummy import Pool as ThreadPool
<2>
<3> pool = ThreadPool(4)
<4> answers = pool.map(self.callDecrypt, self.list_of_objects)
<5>
<6> """for item in self.list_of_objects:
<7> result = item.decrypt(text)
<8> answers.append(result)"""
<9> for answer in answers:
<10> # adds the LC objects together
<11> self.lc = self.lc + answer["lc"]
<12> if answer["IsPlaintext?"]:
<13> return answer
<14>
<15> # so viginere runs ages
<16> # and you cant kill threads in a pool
<17> # so i just run it last lol
<18> result = self.callDecrypt(self.viginere)
<19> if result["IsPlaintext?"]:
<20> return result
<21> return {
<22> "lc": self.lc,
<23> "IsPlaintext?": False,
<24> "Plaintext": None,
<25> "Cipher": None,
<26> "Extra Information": None,
<27> }
<28>
|
===========unchanged ref 0===========
at: Decryptor.basicEncryption.pigLatin
PigLatin(lc)
at: Decryptor.basicEncryption.reverse
Reverse(lc)
at: Decryptor.basicEncryption.viginere
Viginere(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent
callDecrypt(obj)
at: ciphey.Decryptor.basicEncryption.caesar
Caesar(lc)
at: ciphey.Decryptor.basicEncryption.transposition
Transposition(lc)
at: multiprocessing.dummy
Pool(processes: Optional[int]=..., initializer: Optional[Callable[..., Any]]=..., initargs: Iterable[Any]=...) -> Any
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
+ self.trans = tr.Transposition(self.lc)
- # self.trans = Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
- self.list_of_objects = [self.caesar, self.reverse, self.pig]
===========changed ref 1===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def getName(self):
+ return "Transposition"
+
===========changed ref 2===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ if __name__ == "__main__":
+ t = Transposition("a")
+ t.main()
+
===========changed ref 4===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
+
===========changed ref 5===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
+ """
+ ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
+ ██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝
+ ██║ ██║██████╔╝███████║█████╗ ╚████╔╝
+ ██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝
+ ╚██████�</s>
===========changed ref 6===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
# offset: 1
<s>╝
+ ╚██████╗██║██║ ██║ ██║███████╗ ██║
+ © Brandon Skerritt
+ https://github.com/brandonskerritt/ciphey
+ """
try:
import Decryptor.basicEncryption.caesar as ca
import Decryptor.basicEncryption.reverse as re
import Decryptor.basicEncryption.viginere as vi
import Decryptor.basicEncryption.pigLatin as pi
+ import Decryptor.basicEncryption.transposition as tr
except ModuleNotFoundError:
import ciphey.Decryptor.basicEncryption.caesar as ca
import ciphey.Decryptor.basicEncryption.reverse as re
import ciphey.Decryptor.basicEncryption.viginere as vi
import ciphey.Decryptor.basicEncryption.pigLatin as pi
+ import ciphey.Decryptor.basicEncryption.transposition as tr
"""
So I want to assign the prob distribution to objects
so it makes sense to do this?
list of objects
for each item in the prob distribution
replace that with the appropriate object in the list?
So each object has a getName func that returns the name as a str
new_prob_dict = {}
for key, val in self.prob:
for obj in list:
if obj.getName() == key:
new_prob_dict[obj] = val
But I don't need to do all this,</s>
===========changed ref 7===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
# offset: 2
<s>?
The dict comes in already sorted.
So why do I need the probability values if it's sorted?
It'd be easier if I make a list in the same order as the dict?
sooo
list_objs = [caeser, etc]
counter = 0
for key, val in self.prob:
for listCounter, item in enumerate(list_objs):
if item.getName() == key:
# moves the item
list_objs.insert(counter, list_objs.pop(listCounter))
counter = counter + 1
Eventually we get a sorted list of obj
"""
===========changed ref 8===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decrypt(self, text):
+ # Brute-force by looping through every possible key.
- # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ return decryptedText
- decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
0fcb8c744315fe2da9c375da9522fe74a7be7f38
|
Transposition cipher is now implemented but doesn't decrypt
|
<7>:<add> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<add>
<add> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<add>
<add> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<add>
<add> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<add>
<add> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<add>
<add> rteoh add e,D7c1
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7>
<8> # the decryptor components
<9> self.basic = BasicParent(self.lc)
<10> self.hash = HashParent()
<11> self.encoding = EncodingParent(self.lc)
<12>
<13> self.level = 1
<14> self.sickomode = False
<15> self.greppable = grep
<16> self.cipher = cipher
<17>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: ciphey.neuralNetworkMod.nn
NeuralNetwork()
at: mathsHelper
mathsHelper()
===========changed ref 0===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def getName(self):
+ return "Transposition"
+
===========changed ref 1===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 2===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ if __name__ == "__main__":
+ t = Transposition("a")
+ t.main()
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
+
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decrypt(self, text):
+ # Brute-force by looping through every possible key.
- # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ return decryptedText
- decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
===========changed ref 5===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
+ self.trans = tr.Transposition(self.lc)
- # self.trans = Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
- self.list_of_objects = [self.caesar, self.reverse, self.pig]
===========changed ref 6===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def hackTransposition(self, message):
+ print("Hacking...")
+
+ # Python programs can be stopped at any time by pressing Ctrl-C (on
+ # Windows) or Ctrl-D (on Mac and Linux)
+
+ # brute-force by looping through every possible key
+ for key in range(1, len(message)):
+
+ decryptedText = self.decryptMessage(key, message)
+
+ # if self.lc.checkLanguage(decryptedText):
+ # Check with user to see if the decrypted key has been found.
+ if self.lc.checkLanguage(decryptedText):
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": True,
+ "Plaintext": decryptedText,
+ "Cipher": "Transposition",
+ "Extra Information": f"The key is {key}",
+ }
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": False,
+ "Plaintext": None,
+ "Cipher": "Transposition",
+ "Extra Information": None,
+ }
+
===========changed ref 7===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def decrypt(self, text):
self.text = text
from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
answers = pool.map(self.callDecrypt, self.list_of_objects)
"""for item in self.list_of_objects:
result = item.decrypt(text)
answers.append(result)"""
for answer in answers:
# adds the LC objects together
+ print(answer)
self.lc = self.lc + answer["lc"]
if answer["IsPlaintext?"]:
return answer
# so viginere runs ages
# and you cant kill threads in a pool
# so i just run it last lol
result = self.callDecrypt(self.viginere)
if result["IsPlaintext?"]:
return result
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
===========changed ref 8===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decryptMessage(self, key, message):
+ # The transposition decrypt function will simulate the "columns" and
+ # "rows" of the grid that the plaintext is written on by using a list
+ # of strings. First, we need to calculate a few values.
+
+ # The number of "columns" in our transposition grid:
+ numOfColumns = math.ceil(len(message) / key)
+ # The number of "rows" in our grid will need:
+ numOfRows = key
+ # The number of "shaded boxes" in the last "column" of the grid:
+ numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
+
+ # Each string in plaintext represents a column in the grid.
+ plaintext = [""] * numOfColumns
+
+ # The col and row variables point to where in the grid the next
+ # character in the encrypted message will go.
+ col = 0
+ row = 0
+
+ for symbol in message:
+ plaintext[col] += symbol
+ col += 1 # point to next column
+
+ # If there are no more columns OR we're at a shaded box, go back to
+ # the first column and the next row.
+ if (col == numOfColumns) or (
+ col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
+ ):
+ col = 0
+ row += 1
+
+ return "".join(plaintext)
+
|
ciphey.__main__/Ciphey.decryptNormal
|
Modified
|
Ciphey~Ciphey
|
0fcb8c744315fe2da9c375da9522fe74a7be7f38
|
Transposition cipher is now implemented but doesn't decrypt
|
<4>:<add> print(key)
|
# module: ciphey.__main__
class Ciphey:
def decryptNormal(self, bar=None):
<0> for key, val in self.whatToChoose.items():
<1> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<2> if not isinstance(key, str):
<3> key.setProbTable(val)
<4> ret = key.decrypt(self.text)
<5> if ret["IsPlaintext?"]:
<6> print(ret["Plaintext"])
<7> if self.cipher:
<8> if ret["Extra Information"] != None:
<9> print(
<10> "The cipher used is",
<11> ret["Cipher"] + ".",
<12> ret["Extra Information"] + ".",
<13> )
<14> else:
<15> print(ret["Cipher"])
<16> return ret
<17>
<18> if not self.greppable:
<19> bar()
<20>
<21> print("No encryption found. Here's the probabilities we calculated")
<22> import pprint
<23>
<24> pprint.pprint(self.whatToChoose)
<25>
|
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent.EncodingParent
setProbTable(table)
at: ciphey.Decryptor.Hash.hashParent.HashParent
setProbTable(val)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent
setProbTable(prob)
at: ciphey.__main__.Ciphey.__init__
self.level = 1
self.sickomode = False
self.greppable = grep
at: ciphey.__main__.Ciphey.decrypt
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
self.whatToChoose = new_dict
at: collections.OrderedDict
items() -> _OrderedDictItemsView[_KT, _VT]
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# general purpose modules
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text = text
+ self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
+
+ ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
+
+ oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
+
+ edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
+
+ ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
+
+ rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
+
+ meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
+
+ ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
+
+ BRe bwlmprraio po</s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
<s>Boa t,e eitsw il ulpbdofg
+
+ BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
+
+ -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
+
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========changed ref 2===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def getName(self):
+ return "Transposition"
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 4===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ if __name__ == "__main__":
+ t = Transposition("a")
+ t.main()
+
===========changed ref 5===========
+ # module: ciphey.Decryptor.basicEncryption.oldtransposition
+
+
+ class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
+
===========changed ref 6===========
# module: ciphey.Decryptor.basicEncryption.transposition
-
-
class Transposition:
-
def decrypt(self, text):
+ # Brute-force by looping through every possible key.
- # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ return decryptedText
- decryptedText = self.hackTransposition("""ehlol ym aftehrh ellom ym ohteXrX""")
===========changed ref 7===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
+ self.trans = tr.Transposition(self.lc)
- # self.trans = Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
- self.list_of_objects = [self.caesar, self.reverse, self.pig]
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
41b4f59d969b282f9d66405d334a744780647b72
|
I have transposition working on its own, now integration
|
<0>:<add> message=="""Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoec
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> # we could probably multi thread this
<1> for key in range(1, len(message)):
<2> decryptedText = self.decryptMessage(key, message)
<3> # if decrypted text is english, return true
<4> if self.lc.checkLanguage(decryptedText):
<5> print("found decrypted text")
<6> return {
<7> "lc": self.lc,
<8> "IsPlaintext?": True,
<9> "Plaintext": decryptedText,
<10> "Cipher": "Transposition",
<11> "Extra Information": f"The key is {key}",
<12> }
<13> # after all keys, return false
<14> print("no decrypted text")
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": False,
<18> "Plaintext": None,
<19> "Cipher": "Transposition",
<20> "Extra Information": None,
<21> }
<22>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
53f4e0567e35e5b1f8ff7115b01ca2b5d21aca7e
|
why does it work in a file but not integrated
|
<0>:<add> Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoec
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> message=="""Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<1> # we could probably multi thread this
<2> for key in range(1, len(message)):
<3> decryptedText = self.decryptMessage(key, message)
<4> if key == 10:
<5> print(decryptedText)
<6> exit(1)
<7> # if decrypted text is english,</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 1
if self.lc.checkLanguage(decryptedText):
print("found decrypted text")
"""return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}"""
# after all keys, return false
print("no decrypted text")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(self, key, message)
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decryptMessage
|
Modified
|
Ciphey~Ciphey
|
53f4e0567e35e5b1f8ff7115b01ca2b5d21aca7e
|
why does it work in a file but not integrated
|
<0>:<add> # The transposition decrypt function will simulate the "columns" and
<add> # "rows" of the grid that the plaintext is written on by using a list
<add> # of strings. First, we need to calculate a few values.
<add>
<add> # The number of "columns" in our transposition grid:
<add> numOfColumns = math.ceil(len(message) / key)
<del> numOfColumns = int(math.ceil(len(message) / float(key)))
<1>:<add> # The number of "rows" in our grid will need:
<2>:<add> # The number of "shaded boxes" in the last "column" of the grid:
<3>:<add>
<add> # Each string in plaintext represents a column in the grid.
<add> plaintext = [''] * numOfColumns
<del> plaintext = [""] * numOfColumns
<4>:<add>
<add> # The col and row variables point to where in the grid the next
<add> # character in the encrypted message will go.
<add> col = 0
<del> column = 0
<6>:<add>
<7>:<add> plaintext[col] += symbol
<del> plaintext[column] += symbol
<8>:<add> col += 1 # point to next column
<del> column += 1 # Point to the next column.
<10>:<add> # If there are no more columns OR we're at a shaded box, go back to
<add> # the first
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decryptMessage(self, key, message):
<0> numOfColumns = int(math.ceil(len(message) / float(key)))
<1> numOfRows = key
<2> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<3> plaintext = [""] * numOfColumns
<4> column = 0
<5> row = 0
<6> for symbol in message:
<7> plaintext[column] += symbol
<8> column += 1 # Point to the next column.
<9>
<10> if (column == numOfColumns) or (
<11> column == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
<12> ):
<13> column = 0
<14> row += 1
<15> return "".join(plaintext)
<16>
|
===========unchanged ref 0===========
at: math
ceil(x: SupportsFloat, /) -> int
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
+ Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
- message=="""Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 1
<s>b(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# we could probably multi thread this
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
- if key == 10:
- print(decryptedText)
+ print()
- exit(1)
+ print('Possible encryption hack:')
+ </s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 2
<s>Key %s: %s' % (key, decryptedText[:100]))
+ print()
+ print('Enter D for done, or just press Enter to continue hacking:')
+ response = input('> ')
# if decrypted text is english, return true
if self.lc.checkLanguage(decryptedText):
print("found decrypted text")
"""return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}"""
# after all keys, return false
print("no decrypted text")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
test.transhacker/hackTransposition
|
Modified
|
Ciphey~Ciphey
|
53f4e0567e35e5b1f8ff7115b01ca2b5d21aca7e
|
why does it work in a file but not integrated
|
<9>:<del>
<10>:<add> decryptedText = decryptMessage(key, message)
<del> decryptedText = transpositionDecrypt.decryptMessage(key, message)
|
# module: test.transhacker
def hackTransposition(message):
<0> print('Hacking...')
<1>
<2> # Python programs can be stopped at any time by pressing Ctrl-C (on
<3> # Windows) or Ctrl-D (on Mac and Linux)
<4> print('(Press Ctrl-C or Ctrl-D to quit at any time.)')
<5>
<6> # brute-force by looping through every possible key
<7> for key in range(1, len(message)):
<8> print('Trying key #%s...' % (key))
<9>
<10> decryptedText = transpositionDecrypt.decryptMessage(key, message)
<11> print()
<12> print('Possible encryption hack:')
<13> print('Key %s: %s' % (key, decryptedText[:100]))
<14> print()
<15> print('Enter D for done, or just press Enter to continue hacking:')
<16> response = input('> ')
<17>
<18> if response.strip().upper().startswith('D'):
<19> return decryptedText
<20>
<21> return None
<22>
|
===========unchanged ref 0===========
at: test.transhacker
decryptMessage(key, message)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decryptMessage(self, key, message):
+ # The transposition decrypt function will simulate the "columns" and
+ # "rows" of the grid that the plaintext is written on by using a list
+ # of strings. First, we need to calculate a few values.
+
+ # The number of "columns" in our transposition grid:
+ numOfColumns = math.ceil(len(message) / key)
- numOfColumns = int(math.ceil(len(message) / float(key)))
+ # The number of "rows" in our grid will need:
numOfRows = key
+ # The number of "shaded boxes" in the last "column" of the grid:
numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
+
+ # Each string in plaintext represents a column in the grid.
+ plaintext = [''] * numOfColumns
- plaintext = [""] * numOfColumns
+
+ # The col and row variables point to where in the grid the next
+ # character in the encrypted message will go.
+ col = 0
- column = 0
row = 0
+
for symbol in message:
+ plaintext[col] += symbol
- plaintext[column] += symbol
+ col += 1 # point to next column
- column += 1 # Point to the next column.
+ # If there are no more columns OR we're at a shaded box, go back to
+ # the first column and the next row.
- if (column == numOfColumns) or (
+ if (col == numOfColumns) or (col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes):
- column == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
- ):
+ col = 0
- column = 0
row += 1
- return "".join(plaintext)
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
+ Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
- message=="""Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee</s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 1
<s>b(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# we could probably multi thread this
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
- if key == 10:
- print(decryptedText)
+ print()
- exit(1)
+ print('Possible encryption hack:')
+ </s>
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 2
<s>Key %s: %s' % (key, decryptedText[:100]))
+ print()
+ print('Enter D for done, or just press Enter to continue hacking:')
+ response = input('> ')
# if decrypted text is english, return true
if self.lc.checkLanguage(decryptedText):
print("found decrypted text")
"""return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}"""
# after all keys, return false
print("no decrypted text")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
test.transhacker/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
6189f9cbcc52741d96f912c36cdf9c4eef2b0f47
|
Forgot to save the file
|
<0>:<add> print('Hacking...')\\\
<del> print('Hacking...')
|
# module: test.transhacker
class Transposition:
def hackTransposition(self, message):
<0> print('Hacking...')
<1>
<2> # Python programs can be stopped at any time by pressing Ctrl-C (on
<3> # Windows) or Ctrl-D (on Mac and Linux)
<4> print('(Press Ctrl-C or Ctrl-D to quit at any time.)')
<5>
<6> # brute-force by looping through every possible key
<7> for key in range(1, len(message)):
<8> print('Trying key #%s...' % (key))
<9> decryptedText = self.decryptMessage(key, message)
<10> print()
<11> print('Possible encryption hack:')
<12> print('Key %s: %s' % (key, decryptedText[:100]))
<13> print()
<14> print('Enter D for done, or just press Enter to continue hacking:')
<15> response = input('> ')
<16>
<17> if response.strip().upper().startswith('D'):
<18> return decryptedText
<19>
<20> return None
<21>
|
===========unchanged ref 0===========
at: test.transhacker.Transposition
decryptMessage(key, message)
|
test.transhacker/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
fda960ae0d4338a381f035bff01ba31e0574b2e6
|
Implemented internal data packet
|
<0>:<add> print('Hacking...')
<del> print('Hacking...')\\\
|
# module: test.transhacker
class Transposition:
def hackTransposition(self, message):
<0> print('Hacking...')\\\
<1>
<2> # Python programs can be stopped at any time by pressing Ctrl-C (on
<3> # Windows) or Ctrl-D (on Mac and Linux)
<4> print('(Press Ctrl-C or Ctrl-D to quit at any time.)')
<5>
<6> # brute-force by looping through every possible key
<7> for key in range(1, len(message)):
<8> print('Trying key #%s...' % (key))
<9> decryptedText = self.decryptMessage(key, message)
<10> print()
<11> print('Possible encryption hack:')
<12> print('Key %s: %s' % (key, decryptedText[:100]))
<13> print()
<14> print('Enter D for done, or just press Enter to continue hacking:')
<15> response = input('> ')
<16>
<17> if response.strip().upper().startswith('D'):
<18> return decryptedText
<19>
<20> return None
<21>
|
===========unchanged ref 0===========
at: test.transhacker.Transposition.hackTransposition
decryptedText = decryptMessage(key, message)
===========changed ref 0===========
# module: test.transhacker
class Transposition:
+ def getName(self):
+ return "Transposition"
+
===========changed ref 1===========
# module: test.transhacker
class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ print(decryptedText)
+ return decryptedText
+
|
test.transhacker/main
|
Modified
|
Ciphey~Ciphey
|
fda960ae0d4338a381f035bff01ba31e0574b2e6
|
Implemented internal data packet
|
<3>:<add> x = Transposition("hello")
<del>
<4>:<add> hackedMessage = x.decrypt(myMessage)
<del> hackedMessage = hackTransposition(myMessage)
|
# module: test.transhacker
def main():
<0> # You might want to copy & paste this text from the source code at
<1> # http://invpy.com/transpositionHacker.py
<2> myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<3>
<4> hackedMessage = hackTransposition(myMessage)
<5>
<6> if hackedMessage == None:
<7> print('Failed to hack encryption.')
<8> else:
<9> print('Copying hacked message to</s>
|
===========below chunk 0===========
# module: test.transhacker
def main():
# offset: 1
print(hackedMessage)
===========unchanged ref 0===========
at: test.transhacker.Transposition.decryptMessage
numOfColumns = math.ceil(len(message) / key)
numOfRows = key
numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
plaintext = [''] * numOfColumns
===========changed ref 0===========
# module: test.transhacker
class Transposition:
+ def getName(self):
+ return "Transposition"
+
===========changed ref 1===========
# module: test.transhacker
class Transposition:
+
+ def decrypt(self, text):
+ # Brute-force by looping through every possible key.
+ decryptedText = self.hackTransposition(text)
+ print(decryptedText)
+ return decryptedText
+
===========changed ref 2===========
# module: test.transhacker
class Transposition:
def hackTransposition(self, message):
+ print('Hacking...')
- print('Hacking...')\\\
# Python programs can be stopped at any time by pressing Ctrl-C (on
# Windows) or Ctrl-D (on Mac and Linux)
print('(Press Ctrl-C or Ctrl-D to quit at any time.)')
# brute-force by looping through every possible key
for key in range(1, len(message)):
print('Trying key #%s...' % (key))
decryptedText = self.decryptMessage(key, message)
print()
print('Possible encryption hack:')
print('Key %s: %s' % (key, decryptedText[:100]))
print()
print('Enter D for done, or just press Enter to continue hacking:')
response = input('> ')
if response.strip().upper().startswith('D'):
return decryptedText
return None
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
aa94038ffe11be324649f88608201db1b161c97a
|
Updating some things
|
<0>:<add> print("Hacking...")
<add>
<add> print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
<add>
<add> # brute-force by looping through every possible key
<del> Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<1>:<del> # we could probably multi thread this
<3>:<add> print("Trying key #%s..." % (key))
<5>:<add> print("Possible encryption hack:")
<del> print('Possible encryption hack:')
<6>:<add> print("Key %s: %s" % (key, decryptedText[:100]))
<del> print('Key %s: %s' % (key, decryptedText[:
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<1> # we could probably multi thread this
<2> for key in range(1, len(message)):
<3> decryptedText = self.decryptMessage(key, message)
<4> print()
<5> print('Possible encryption hack:')
<6> print('Key %s: %s' % (key, decryptedText[:</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# offset: 1
print()
print('Enter D for done, or just press Enter to continue hacking:')
response = input('> ')
# if decrypted text is english, return true
if self.lc.checkLanguage(decryptedText):
print("found decrypted text")
"""return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}"""
# after all keys, return false
print("no decrypted text")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.hackTransposition
decryptedText = self.decryptMessage(key, message)
at: math
ceil(x: SupportsFloat, /) -> int
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
- def main(self):
- # this main exists so i can test it
- myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
-
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
-
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
-
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
-
- ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
-
- rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
-
- meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
-
- ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
-
- BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-
- -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
- hackedMessage = self.</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
- def main(self):
# offset: 1
<s>ideI nn rms iehn tsigaBmuoetcetias rn"""
-
- hackedMessage = self.hackTransposition(myMessage)
-
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
"""
██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝
██║ ██║██████╔╝███████║█████╗ ╚████╔╝
██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝
╚██████╗██║�</s>
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.transposition
# offset: 1
<s>��█████╗██║██║ ██║ ██║███████╗ ██║
© Brandon Skerritt
https://github.com/brandonskerritt/ciphey
+
+ Code taken from http://invpy.com/transpositionHacker.py
+ Permission granted from author.
"""
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
aa94038ffe11be324649f88608201db1b161c97a
|
Updating some things
|
<2>:<add> print(decryptedText)
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> decryptedText = self.hackTransposition(text)
<2> return decryptedText
<3>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.decryptMessage
numOfColumns = math.ceil(len(message) / key)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
- def main(self):
- # this main exists so i can test it
- myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
-
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
-
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
-
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
-
- ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
-
- rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
-
- meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
-
- ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
-
- BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-
- -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
- hackedMessage = self.</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
- def main(self):
# offset: 1
<s>ideI nn rms iehn tsigaBmuoetcetias rn"""
-
- hackedMessage = self.hackTransposition(myMessage)
-
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
"""
██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
██╔════╝██║██╔══██╗██║ ██║██╔════╝╚██╗ ██╔╝
██║ ██║██████╔╝███████║█████╗ ╚████╔╝
██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝
╚██████╗██║�</s>
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.transposition
# offset: 1
<s>��█████╗██║██║ ██║ ██║███████╗ ██║
© Brandon Skerritt
https://github.com/brandonskerritt/ciphey
+
+ Code taken from http://invpy.com/transpositionHacker.py
+ Permission granted from author.
"""
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
+ print("Hacking...")
+
+ print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
+
+ # brute-force by looping through every possible key
- Message = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
- # we could probably multi thread this
for key in range(1, len(message)):</s>
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
803b94769a5e42f664b4f47b2bdce08987c58637
|
Switching branches
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> B</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Hash.hashParent
HashParent()
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.mathsHelper
mathsHelper()
at: languageCheckerMod.LanguageChecker
LanguageChecker()
at: neuralNetworkMod.nn
NeuralNetwork()
|
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
004f0db3ba142fbfaadab2ed047e603f4d639760
|
Working on improving the progress bars with RICH
|
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Hash.hashParent
HashParent()
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: languageCheckerMod.LanguageChecker
LanguageChecker()
at: mathsHelper
mathsHelper()
at: neuralNetworkMod.nn
NeuralNetwork()
|
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
8a62f9b6ea7cc27c427bdcd017d910de8a5696e9
|
Transposition works, now to implement LC
|
<1>:<add> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcno
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> decryptedText = self.hackTransposition(text)
<2> print(decryptedText)
<3> return decryptedText
<4>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
hackTransposition(message)
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
8a62f9b6ea7cc27c427bdcd017d910de8a5696e9
|
Transposition works, now to implement LC
|
<13>:<add> help="Do you want information on the cipher used?",
<del> help="Do you want information on the cipher?",
<26>:<del> """
<27>:<del> ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
<28>:<del> ██�
|
# module: ciphey.__main__
def main():
<0> parser = argparse.ArgumentParser(
<1> description="Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it."
<2> )
<3> # parser.add_argument('-f','--file', help='File you want to decrypt', required=False)
<4> # parser.add_argument('-l','--level', help='How many levels of decryption you want (the more levels, the slower it is)', required=False)
<5> parser.add_argument(
<6> "-g", "--greppable", help="Are you grepping this output?", required=False
<7> )
<8> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<9> # parser.add_argument('-s','--sicko-mode', help='If it is encrypted Ciphey WILL find it', required=False)
<10> parser.add_argument(
<11> "-c",
<12> "--printcipher",
<13> help="Do you want information on the cipher?",
<14> required=False,
<15> )
<16>
<17> args = vars(parser.parse_args())
<18> if args["printcipher"] != None:
<19> cipher = True
<20> else:
<21> cipher = False
<22> if args["greppable"] != None:
<23> greppable = True
<24> else:
<25> greppable = False
<26> """
<27> ██████╗██╗██████╗ ██╗ ██╗███████╗██╗ ██╗
<28> ██�</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def main():
# offset: 1
██║ ██║██████╔╝███████║█████╗ ╚████╔╝
██║ ██║██╔═══╝ ██╔══██║██╔══╝ ╚██╔╝
╚██████╗██║██║ ██║ ██║███████╗ ██║
Made by Brandon Skerritt"""
# uryyb zl sngure uryyb zl zbgure naq v ernyyl qb yvxr n tbbq ratyvfu oernxsnfg
if args["text"]:
cipherObj = Ciphey(args["text"], greppable, cipher)
cipherObj.decrypt()
else:
print(
"You didn't supply any arguments. Look at the help menu with -h or --help"
)
===========unchanged ref 0===========
at: argparse
ArgumentParser(prog: Optional[str]=..., usage: Optional[str]=..., description: Optional[str]=..., epilog: Optional[str]=..., parents: Sequence[ArgumentParser]=..., formatter_class: _FormatterClass=..., prefix_chars: str=..., fromfile_prefix_chars: Optional[str]=..., argument_default: Any=..., conflict_handler: str=..., add_help: bool=..., allow_abbrev: bool=...)
at: argparse.ArgumentParser
parse_args(args: Optional[Sequence[Text]], namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]]=...) -> Namespace
parse_args(*, namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]], namespace: _N) -> _N
parse_args(*, namespace: _N) -> _N
at: argparse._ActionsContainer
add_argument(*name_or_flags: Text, action: Union[Text, Type[Action]]=..., nargs: Union[int, Text]=..., const: Any=..., default: Any=..., type: Union[Callable[[Text], _T], Callable[[str], _T], FileType]=..., choices: Iterable[_T]=..., required: bool=..., help: Optional[Text]=..., metavar: Optional[Union[Text, Tuple[Text, ...]]]=..., dest: Optional[Text]=..., version: Text=..., **kwargs: Any) -> Action
at: ciphey.__main__
Ciphey(text, grep=False, cipher=False)
at: ciphey.__main__.Ciphey
decrypt()
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
+ text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
+
decryptedText = self.hackTransposition(text)
print(decryptedText)
return decryptedText
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
39963b83ad48c9258e7cd336641b1b3b0f030681
|
LC doesn't operate properly
|
<4>:<del> print(decryptedText)
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<2>
<3> decryptedText = self.hackTransposition(text)
<4> print(decryptedText)
<5> return decryptedText
<6>
| |
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
39963b83ad48c9258e7cd336641b1b3b0f030681
|
LC doesn't operate properly
|
<0>:<del> print("Hacking...")
<1>:<del>
<2>:<del> print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
<3>:<del>
<4>:<add> print("hacking transposition")
<6>:<del> print("Trying key #%s..." % (key))
<8>:<add> print(key)
<del> print()
<9>:<add> # if decrypted english is found, return them
<add> if key == 10:
<add> print(decryptedText)
<add> print("checking LC")
<add> result = self.lc.checkLanguage(decryptedText)
<del> print("Possible encryption hack:")
<10>:<del> print("Key %s: %s" % (key, decryptedText[:100]))
<11>:<add> print(result)
<del> print()
<12>:<del> print("Enter D for done, or just press Enter to continue hacking:")
<13>:<del> response = input("> ")
<14>:<del>
<15>:<del> if response.strip().upper().startswith("D"):
<16>:<del> # it is found
<17>:<add> if result:
<add> print("*******************LC returns TRUE")
<add> exit(1)
<24>:<add> if key == 11:
<add> import time
<add> time.sleep(60)
<add> exit(1)
<add> exit(1)
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> print("Hacking...")
<1>
<2> print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
<3>
<4> # brute-force by looping through every possible key
<5> for key in range(1, len(message)):
<6> print("Trying key #%s..." % (key))
<7> decryptedText = self.decryptMessage(key, message)
<8> print()
<9> print("Possible encryption hack:")
<10> print("Key %s: %s" % (key, decryptedText[:100]))
<11> print()
<12> print("Enter D for done, or just press Enter to continue hacking:")
<13> response = input("> ")
<14>
<15> if response.strip().upper().startswith("D"):
<16> # it is found
<17> return {
<18> "lc": self.lc,
<19> "IsPlaintext?": True,
<20> "Plaintext": decryptedText,
<21> "Cipher": "Transposition",
<22> "Extra Information": f"The key is {key}",
<23> }
<24>
<25> # it is not found
<26> return {
<27> "lc": self.lc,
<28> "IsPlaintext?": False,
<29> "Plaintext": None,
<30> "Cipher": "Transposition",
<31> "Extra Information": None,
<32> }
<33>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: time
sleep(secs: float) -> None
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
decryptedText = self.hackTransposition(text)
- print(decryptedText)
return decryptedText
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
39963b83ad48c9258e7cd336641b1b3b0f030681
|
LC doesn't operate properly
|
<11>:<del> print(answer)
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def decrypt(self, text):
<0> self.text = text
<1> from multiprocessing.dummy import Pool as ThreadPool
<2>
<3> pool = ThreadPool(4)
<4> answers = pool.map(self.callDecrypt, self.list_of_objects)
<5>
<6> """for item in self.list_of_objects:
<7> result = item.decrypt(text)
<8> answers.append(result)"""
<9> for answer in answers:
<10> # adds the LC objects together
<11> print(answer)
<12> self.lc = self.lc + answer["lc"]
<13> if answer["IsPlaintext?"]:
<14> return answer
<15>
<16> # so viginere runs ages
<17> # and you cant kill threads in a pool
<18> # so i just run it last lol
<19> result = self.callDecrypt(self.viginere)
<20> if result["IsPlaintext?"]:
<21> return result
<22> return {
<23> "lc": self.lc,
<24> "IsPlaintext?": False,
<25> "Plaintext": None,
<26> "Cipher": None,
<27> "Extra Information": None,
<28> }
<29>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent
callDecrypt(obj)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent.__init__
self.lc = lc
self.viginere = vi.Viginere(self.lc)
self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
at: multiprocessing.dummy
Pool(processes: Optional[int]=..., initializer: Optional[Callable[..., Any]]=..., initargs: Iterable[Any]=...) -> Any
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
- print("Hacking...")
-
- print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
-
+ print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
- print("Trying key #%s..." % (key))
decryptedText = self.decryptMessage(key, message)
+ print(key)
- print()
+ # if decrypted english is found, return them
+ if key == 10:
+ print(decryptedText)
+ print("checking LC")
+ result = self.lc.checkLanguage(decryptedText)
- print("Possible encryption hack:")
- print("Key %s: %s" % (key, decryptedText[:100]))
+ print(result)
- print()
- print("Enter D for done, or just press Enter to continue hacking:")
- response = input("> ")
-
- if response.strip().upper().startswith("D"):
- # it is found
+ if result:
+ print("*******************LC returns TRUE")
+ exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
+ if key == 11:
+ import time
+ time.sleep(60)
+ exit(1)
+ exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
decryptedText = self.hackTransposition(text)
- print(decryptedText)
return decryptedText
|
ciphey.__main__/Ciphey.decryptNormal
|
Modified
|
Ciphey~Ciphey
|
39963b83ad48c9258e7cd336641b1b3b0f030681
|
LC doesn't operate properly
|
<4>:<del> print(key)
<23>:<del> import pprint
<24>:<del>
<25>:<del> pprint.pprint(self.whatToChoose)
|
# module: ciphey.__main__
class Ciphey:
def decryptNormal(self, bar=None):
<0> for key, val in self.whatToChoose.items():
<1> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<2> if not isinstance(key, str):
<3> key.setProbTable(val)
<4> print(key)
<5> ret = key.decrypt(self.text)
<6> if ret["IsPlaintext?"]:
<7> print(ret["Plaintext"])
<8> if self.cipher:
<9> if ret["Extra Information"] != None:
<10> print(
<11> "The cipher used is",
<12> ret["Cipher"] + ".",
<13> ret["Extra Information"] + ".",
<14> )
<15> else:
<16> print(ret["Cipher"])
<17> return ret
<18>
<19> if not self.greppable:
<20> bar()
<21>
<22> print("No encryption found. Here's the probabilities we calculated")
<23> import pprint
<24>
<25> pprint.pprint(self.whatToChoose)
<26>
|
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent.EncodingParent
decrypt(text)
at: Decryptor.Hash.hashParent.HashParent
decrypt(text)
at: Decryptor.basicEncryption.basic_parent.BasicParent
setProbTable(prob)
at: argparse
ArgumentParser(prog: Optional[str]=..., usage: Optional[str]=..., description: Optional[str]=..., epilog: Optional[str]=..., parents: Sequence[ArgumentParser]=..., formatter_class: _FormatterClass=..., prefix_chars: str=..., fromfile_prefix_chars: Optional[str]=..., argument_default: Any=..., conflict_handler: str=..., add_help: bool=..., allow_abbrev: bool=...)
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent
setProbTable(table)
at: ciphey.Decryptor.Hash.hashParent.HashParent
setProbTable(val)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent
decrypt(text)
===========unchanged ref 1===========
at: ciphey.__main__.Ciphey.__init__
self.text = text
self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
self.greppable = grep
self.cipher = cipher
===========unchanged ref 2===========
at: ciphey.__main__.Ciphey.decrypt
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
self.whatToChoose = new_dict
at: collections.OrderedDict
update = __update = _collections_abc.MutableMapping.update
update = __update = _collections_abc.MutableMapping.update
items() -> _OrderedDictItemsView[_KT, _VT]
__ne__ = _collections_abc.MutableMapping.__ne__
__marker = object()
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def decrypt(self, text):
self.text = text
from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
answers = pool.map(self.callDecrypt, self.list_of_objects)
"""for item in self.list_of_objects:
result = item.decrypt(text)
answers.append(result)"""
for answer in answers:
# adds the LC objects together
- print(answer)
self.lc = self.lc + answer["lc"]
if answer["IsPlaintext?"]:
return answer
# so viginere runs ages
# and you cant kill threads in a pool
# so i just run it last lol
result = self.callDecrypt(self.viginere)
if result["IsPlaintext?"]:
return result
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
- print("Hacking...")
-
- print("(Press Ctrl-C or Ctrl-D to quit at any time.)")
-
+ print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
- print("Trying key #%s..." % (key))
decryptedText = self.decryptMessage(key, message)
+ print(key)
- print()
+ # if decrypted english is found, return them
+ if key == 10:
+ print(decryptedText)
+ print("checking LC")
+ result = self.lc.checkLanguage(decryptedText)
- print("Possible encryption hack:")
- print("Key %s: %s" % (key, decryptedText[:100]))
+ print(result)
- print()
- print("Enter D for done, or just press Enter to continue hacking:")
- response = input("> ")
-
- if response.strip().upper().startswith("D"):
- # it is found
+ if result:
+ print("*******************LC returns TRUE")
+ exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
+ if key == 11:
+ import time
+ time.sleep(60)
+ exit(1)
+ exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
b60ea6cd203b40c03220f7ef8d971870aa043974
|
finalupload
|
<23>:<add> time.sleep(60)\
<del> time.sleep(60)
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> print("hacking transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> decryptedText = self.decryptMessage(key, message)
<4> print(key)
<5> # if decrypted english is found, return them
<6> if key == 10:
<7> print(decryptedText)
<8> print("checking LC")
<9> result = self.lc.checkLanguage(decryptedText)
<10> print(result)
<11> if result:
<12> print("*******************LC returns TRUE")
<13> exit(1)
<14> return {
<15> "lc": self.lc,
<16> "IsPlaintext?": True,
<17> "Plaintext": decryptedText,
<18> "Cipher": "Transposition",
<19> "Extra Information": f"The key is {key}",
<20> }
<21> if key == 11:
<22> import time
<23> time.sleep(60)
<24> exit(1)
<25> exit(1)
<26>
<27> # it is not found
<28> return {
<29> "lc": self.lc,
<30> "IsPlaintext?": False,
<31> "Plaintext": None,
<32> "Cipher": "Transposition",
<33> "Extra Information": None,
<34> }
<35>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: time
sleep(secs: float) -> None
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
d5619a744a30eb60fa3ccb5c8a57d76ab67c7b54
|
Chi squared is broken
|
<23>:<add> time.sleep(60)
<del> time.sleep(60)\
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> print("hacking transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> decryptedText = self.decryptMessage(key, message)
<4> print(key)
<5> # if decrypted english is found, return them
<6> if key == 10:
<7> print(decryptedText)
<8> print("checking LC")
<9> result = self.lc.checkLanguage(decryptedText)
<10> print(result)
<11> if result:
<12> print("*******************LC returns TRUE")
<13> exit(1)
<14> return {
<15> "lc": self.lc,
<16> "IsPlaintext?": True,
<17> "Plaintext": decryptedText,
<18> "Cipher": "Transposition",
<19> "Extra Information": f"The key is {key}",
<20> }
<21> if key == 11:
<22> import time
<23> time.sleep(60)\
<24> exit(1)
<25> exit(1)
<26>
<27> # it is not found
<28> return {
<29> "lc": self.lc,
<30> "IsPlaintext?": False,
<31> "Plaintext": None,
<32> "Cipher": "Transposition",
<33> "Extra Information": None,
<34> }
<35>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: time
sleep(secs: float) -> None
|
ciphey.languageCheckerMod.chisquared/chiSquared.checkChi
|
Modified
|
Ciphey~Ciphey
|
d5619a744a30eb60fa3ccb5c8a57d76ab67c7b54
|
Chi squared is broken
|
<0>:<add> if "CHARLES" in text.upper():
<add> print("************************************************************************************")
<add> print("************************************************************************************")
<add> print("************************************************************************************")
<19>:<add> print(f"The chi as a list is {self.chisAsaList[-1]}")
<add> tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<add> print(f"std * chiSig {tempy}")
<add> print(f"Average is {self.average}")
<add> print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
<add> print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
<add> if "CHARLES" in text.upper():
<add> print("************************************************************************************")
<add> print("************************************************************************************
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
<0> """Checks to see if the Chi score is good
<1> if it is, it returns True
<2> Call this when you want to determine whether something is likely to be Chi or not
<3>
<4> Arguments:
<5> * text - the text you want to run a Chi Squared score on
<6>
<7> Outputs:
<8> * True - if it has a significantly lower chi squared score
<9> * False - if it doesn't have a significantly lower chi squared score
<10> """
<11> # TODO 20% isn't optimal
<12> # runs after every chi squared to see if it's 1 significantly lower than averae
<13> # the or statement is bc if the program has just started I don't want it to ignore the
<14> # ones at the start
<15> self.chiSquared(text)
<16> # If the latest chi squared is less than the standard deviation
<17> # or if not many chi squares have been calculated
<18> # or if every single letter in a text appears exactly once (pangram)
<19> if (
<20> self.chisAsaList[-1]
<21> <= abs(
<22> self.average
<23> - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
<24> )
<25> or self.totalDone < self.totalDoneThreshold
<26> or self.totalEqual
<27> ):
<28> return True
<29> else:
<30> return False
<31>
|
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
print(key)
# if decrypted english is found, return them
if key == 10:
print(decryptedText)
print("checking LC")
result = self.lc.checkLanguage(decryptedText)
print(result)
if result:
print("*******************LC returns TRUE")
exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
if key == 11:
import time
+ time.sleep(60)
- time.sleep(60)\
exit(1)
exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
ciphey.languageCheckerMod.chisquared/chiSquared.chiSquared
|
Modified
|
Ciphey~Ciphey
|
d5619a744a30eb60fa3ccb5c8a57d76ab67c7b54
|
Chi squared is broken
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
<0> """Creates letter frequency of text and compares that to the letter frequency of the language"""
<1>
<2> # if all items of the dictionary are the same, then it's a normal distribution
<3> # examples of this could be "the quick brown fox jumped over the lazy dog"
<4>
<5> letterFreq = self.getLetterFreq(text)
<6> self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
<7>
<8> # so we dont have to calculate len more than once
<9> # turns them into probabilities (frequency distribution)
<10> lenOfString = len(text)
<11> totalLetterFreq = 0.0
<12> for key, value in letterFreq.items():
<13> try:
<14> letterFreq[key] = value / lenOfString
<15> totalLetterFreq = totalLetterFreq + value
<16> except ZeroDivisionError as e:
<17> print(
<18> 'Error, you have entered an empty string :( The error is "'
<19> + str(e)
<20> + '" on line 34 of LanguageChecker.py (function chiSquared)'
<21> )
<22> exit(1)
<23>
<24> # calculates chi squared of each language
<25> maxChiSquare = 0.00
<26> languagesChi = {}
<27>
<28> for language in self.languages:
<29> # , list(languages[language].values())
<30> temp = self.myChi(letterFreq, self.languages[language])
<31> languagesChi[language] = temp
<32> if temp > maxChiSquare:
<33> self.highestLanguage = language
<34> maxChiSquare = temp
<35> self.chisAsaList.append(maxChiSquare)
<36> # calculates running average
<37> self.oldAverage = self.average
<38> self.totalDone += 1
<39> # calculates</s>
|
===========below chunk 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
self.average = (self.totalChi + maxChiSquare) / self.totalDone
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.chisquared.chiSquared
getLetterFreq(text)
at: ciphey.languageCheckerMod.chisquared.chiSquared.__init__
self.mh = mh.mathsHelper()
self.totalEqual = False
at: mathsHelper.mathsHelper
checkEqual(a)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
+ if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")
+ print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ print(f"The chi as a list is {self.chisAsaList[-1]}")
+ tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ print(f"std * chiSig {tempy}")
+ print(f"Average is {self.average}")
+ print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
+ print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
+ if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")</s>
===========changed ref 1===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
<s> if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")
+ print("************************************************************************************")
+ import time
+ time.sleep(60)
+ stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
if (
self.chisAsaList[-1]
+ <= abs(stdSignif)
- <= abs(
- self.average
- - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- )
or self.totalDone < self.totalDoneThreshold
+ or self.totalEqual
- or self.totalEqual
+ or float(self.chisAsaList[-1]) < stdSignif + 0.1
+ or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
print(key)
# if decrypted english is found, return them
if key == 10:
print(decryptedText)
print("checking LC")
result = self.lc.checkLanguage(decryptedText)
print(result)
if result:
print("*******************LC returns TRUE")
exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
if key == 11:
import time
+ time.sleep(60)
- time.sleep(60)\
exit(1)
exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
d5619a744a30eb60fa3ccb5c8a57d76ab67c7b54
|
Chi squared is broken
|
<3>:<add> print(f"The chi squared score is {result}")
<5>:<add> print(f"The dictionary checker score is {result2}")
|
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> if result:
<4> result2 = self.dictionary.confirmlanguage(text, "English")
<5> if result2:
<6> return True
<7> else:
<8> return False
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
confirmlanguage(text, language)
at: languageCheckerMod.chisquared.chiSquared
checkChi(text)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
print(key)
# if decrypted english is found, return them
if key == 10:
print(decryptedText)
print("checking LC")
result = self.lc.checkLanguage(decryptedText)
print(result)
if result:
print("*******************LC returns TRUE")
exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
if key == 11:
import time
+ time.sleep(60)
- time.sleep(60)\
exit(1)
exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
"""Creates letter frequency of text and compares that to the letter frequency of the language"""
# if all items of the dictionary are the same, then it's a normal distribution
# examples of this could be "the quick brown fox jumped over the lazy dog"
letterFreq = self.getLetterFreq(text)
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
# so we dont have to calculate len more than once
# turns them into probabilities (frequency distribution)
lenOfString = len(text)
totalLetterFreq = 0.0
for key, value in letterFreq.items():
try:
letterFreq[key] = value / lenOfString
totalLetterFreq = totalLetterFreq + value
except ZeroDivisionError as e:
print(
'Error, you have entered an empty string :( The error is "'
+ str(e)
+ '" on line 34 of LanguageChecker.py (function chiSquared)'
)
exit(1)
# calculates chi squared of each language
maxChiSquare = 0.00
languagesChi = {}
for language in self.languages:
# , list(languages[language].values())
temp = self.myChi(letterFreq, self.languages[language])
languagesChi[language] = temp
if temp > maxChiSquare:
self.highestLanguage = language
maxChiSquare = temp
self.chisAsaList.append(maxChiSquare)
# calculates running average
self.oldAverage = self.average
self.totalDone += 1
# calculates a running average, maxChiSquare is the new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
</s>
===========changed ref 2===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
<s> new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
+ print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
===========changed ref 3===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
+ if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")
+ print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ print(f"The chi as a list is {self.chisAsaList[-1]}")
+ tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ print(f"std * chiSig {tempy}")
+ print(f"Average is {self.average}")
+ print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
+ print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
+ if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")</s>
===========changed ref 4===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
<s> if "CHARLES" in text.upper():
+ print("************************************************************************************")
+ print("************************************************************************************")
+ print("************************************************************************************")
+ import time
+ time.sleep(60)
+ stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
if (
self.chisAsaList[-1]
+ <= abs(stdSignif)
- <= abs(
- self.average
- - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- )
or self.totalDone < self.totalDoneThreshold
+ or self.totalEqual
- or self.totalEqual
+ or float(self.chisAsaList[-1]) < stdSignif + 0.1
+ or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
|
ciphey.languageCheckerMod.chisquared/chiSquared.checkChi
|
Modified
|
Ciphey~Ciphey
|
d38baf8a783308c9713aba015c025c1727925b33
|
Creating tests for Chi Squared and Dictionary Checker using Babbage
|
<23>:<add> stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<29>:<add> print(float(self.chisAsaList[-1]) < stdSignif + 0.1)
<add> print(float(self.chisAsaList[-1]) > stdSignif - 0.1)
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
<0> if "CHARLES" in text.upper():
<1> print("************************************************************************************")
<2> print("************************************************************************************")
<3> print("************************************************************************************")
<4> """Checks to see if the Chi score is good
<5> if it is, it returns True
<6> Call this when you want to determine whether something is likely to be Chi or not
<7>
<8> Arguments:
<9> * text - the text you want to run a Chi Squared score on
<10>
<11> Outputs:
<12> * True - if it has a significantly lower chi squared score
<13> * False - if it doesn't have a significantly lower chi squared score
<14> """
<15> # TODO 20% isn't optimal
<16> # runs after every chi squared to see if it's 1 significantly lower than averae
<17> # the or statement is bc if the program has just started I don't want it to ignore the
<18> # ones at the start
<19> self.chiSquared(text)
<20> # If the latest chi squared is less than the standard deviation
<21> # or if not many chi squares have been calculated
<22> # or if every single letter in a text appears exactly once (pangram)
<23> print(f"The chi as a list is {self.chisAsaList[-1]}")
<24> tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<25> print(f"std * chiSig {tempy}")
<26> print(f"Average is {self.average}")
<27> print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
<28> print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
<29> if "CHARLES" in text.upper():
</s>
|
===========below chunk 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
print("************************************************************************************")
print("************************************************************************************")
import time
time.sleep(60)
stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
if (
self.chisAsaList[-1]
<= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
or self.totalEqual
or float(self.chisAsaList[-1]) < stdSignif + 0.1
or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.chisquared.chiSquared
chiSquared(text)
at: ciphey.languageCheckerMod.chisquared.chiSquared.__init__
self.average = 0.0
self.totalDone = 0.0
self.totalEqual = False
self.chisAsaList = []
self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it
self.totalDoneThreshold = 10
self.oldstandarddeviation = 0.00
at: ciphey.languageCheckerMod.chisquared.chiSquared.chiSquared
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
self.totalDone += 1
self.average = (self.totalChi + maxChiSquare) / self.totalDone
self.oldstandarddeviation = abs(self.standarddeviation)
|
ciphey.languageCheckerMod.chisquared/chiSquared.checkChi
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
<0>:<del> if "CHARLES" in text.upper():
<1>:<del> print("************************************************************************************")
<2>:<del> print("************************************************************************************")
<3>:<del> print("************************************************************************************")
<23>:<add> stdSignif = float(
<add> self.average
<del> stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<24>:<del> print(f"The chi as a list is {self.chisAsaList[-1]}")
<25>:<add> - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
<del> tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<26>:<add> )
<add> tempy = abs(
<add> self.average
<del> print(f"std * chiSig {tempy}")
<27>:<del> print(f"Average is {self.average}")
<28>:<add> - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
<del> print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
<29>:<del> print(self.chisAsaList[-1]<= abs(self.average- (
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
<0> if "CHARLES" in text.upper():
<1> print("************************************************************************************")
<2> print("************************************************************************************")
<3> print("************************************************************************************")
<4> """Checks to see if the Chi score is good
<5> if it is, it returns True
<6> Call this when you want to determine whether something is likely to be Chi or not
<7>
<8> Arguments:
<9> * text - the text you want to run a Chi Squared score on
<10>
<11> Outputs:
<12> * True - if it has a significantly lower chi squared score
<13> * False - if it doesn't have a significantly lower chi squared score
<14> """
<15> # TODO 20% isn't optimal
<16> # runs after every chi squared to see if it's 1 significantly lower than averae
<17> # the or statement is bc if the program has just started I don't want it to ignore the
<18> # ones at the start
<19> self.chiSquared(text)
<20> # If the latest chi squared is less than the standard deviation
<21> # or if not many chi squares have been calculated
<22> # or if every single letter in a text appears exactly once (pangram)
<23> stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<24> print(f"The chi as a list is {self.chisAsaList[-1]}")
<25> tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
<26> print(f"std * chiSig {tempy}")
<27> print(f"Average is {self.average}")
<28> print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
<29> print(self.chisAsaList[-1]<= abs(self.average- (</s>
|
===========below chunk 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
print(float(self.chisAsaList[-1]) < stdSignif + 0.1)
print(float(self.chisAsaList[-1]) > stdSignif - 0.1)
if "CHARLES" in text.upper():
print("************************************************************************************")
print("************************************************************************************")
print("************************************************************************************")
if (
self.chisAsaList[-1]
<= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
or self.totalEqual
or float(self.chisAsaList[-1]) < stdSignif + 0.1
or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.chisquared.chiSquared
getLetterFreq(self, text)
chiSquared(text)
at: ciphey.languageCheckerMod.chisquared.chiSquared.__init__
self.average = 0.0
self.totalDone = 0.0
self.totalEqual = False
self.chisAsaList = []
self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it
self.totalDoneThreshold = 10
self.oldstandarddeviation = 0.00
at: ciphey.languageCheckerMod.chisquared.chiSquared.chiSquared
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
self.totalDone += 1
self.average = (self.totalChi + maxChiSquare) / self.totalDone
self.oldstandarddeviation = abs(self.standarddeviation)
at: ciphey.languageCheckerMod.chisquared.chiSquared.getLetterFreq
letterFreq = {
"a": 0,
"b": 0,
"c": 0,
"d": 0,
"e": 0,
"f": 0,
"g": 0,
"h": 0,
"i": 0,
"j": 0,
"k": 0,
"l": 0,
"m": 0,
"n": 0,
"o": 0,
"p": 0,
"q": 0,
"r": 0,
"s": 0,
"t": 0,
"u": 0,
"v": 0,
"w": 0,
"x": 0,
"y": 0,
"z": 0,
}
|
ciphey.languageCheckerMod.chisquared/chiSquared.chiSquared
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
<0> """Creates letter frequency of text and compares that to the letter frequency of the language"""
<1>
<2> # if all items of the dictionary are the same, then it's a normal distribution
<3> # examples of this could be "the quick brown fox jumped over the lazy dog"
<4>
<5> letterFreq = self.getLetterFreq(text)
<6> self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
<7>
<8> # so we dont have to calculate len more than once
<9> # turns them into probabilities (frequency distribution)
<10> lenOfString = len(text)
<11> totalLetterFreq = 0.0
<12> for key, value in letterFreq.items():
<13> try:
<14> letterFreq[key] = value / lenOfString
<15> totalLetterFreq = totalLetterFreq + value
<16> except ZeroDivisionError as e:
<17> print(
<18> 'Error, you have entered an empty string :( The error is "'
<19> + str(e)
<20> + '" on line 34 of LanguageChecker.py (function chiSquared)'
<21> )
<22> exit(1)
<23>
<24> # calculates chi squared of each language
<25> maxChiSquare = 0.00
<26> languagesChi = {}
<27>
<28> for language in self.languages:
<29> # , list(languages[language].values())
<30> temp = self.myChi(letterFreq, self.languages[language])
<31> languagesChi[language] = temp
<32> if temp > maxChiSquare:
<33> self.highestLanguage = language
<34> maxChiSquare = temp
<35> self.chisAsaList.append(maxChiSquare)
<36> # calculates running average
<37> self.oldAverage = self.average
<38> self.totalDone += 1
<39> # calculates</s>
|
===========below chunk 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
self.average = (self.totalChi + maxChiSquare) / self.totalDone
print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.chisquared.chiSquared
myChi(text, distribution)
myChi(self, text, distribution)
===========unchanged ref 1===========
at: ciphey.languageCheckerMod.chisquared.chiSquared.__init__
self.languages = {
"English":
# [0.0855, 0.0160, 0.0316, 0.0387, 0.1210,0.0218, 0.0209, 0.0496, 0.0733, 0.0022,0.0081, 0.0421, 0.0253, 0.0717, 0.0747,0.0207, 0.0010, 0.0633, 0.0673, 0.0894,0.0268, 0.0106, 0.0183, 0.0019, 0.0172,0.0011]
# {'A': 8.12, 'B': 1.49, 'C': 2.71, 'D': 4.32, 'E': 12.02, 'F': 2.3, 'G': 2.03, 'H': 5.92, 'I': 7.31, 'J': 0.1, 'K': 0.69, 'L': 3.98, 'M': 2.61, 'N': 6.95, 'O': 7.68, 'P': 1.82, 'Q': 0.11, 'R': 6.02, 'S': 6.28, 'T': 9.1, 'U': 2.88, 'V': 1.11, 'W': 2.09, 'X': 0.17, 'Y': 2.11, 'Z': 0.07}
[
0.0812,
0.0271,
0.0149,
0.1202,
0.0432,
0.0203,
0.023,
0.0731,
0.0592,
0.0069,
0.001,
0.026099999999999998,
0.0398,
0.0768,
0.0695,
0.0011,
0.0182,
0.06280000000000001</s>
===========unchanged ref 2===========
self.average = 0.0
self.totalDone = 0.0
self.oldAverage = 0.0
self.highestLanguage = ""
self.totalChi = 0.0
self.chisAsaList = []
self.standarddeviation = 0.00 # the standard deviation I use
self.oldstandarddeviation = 0.00
at: numpy.core.fromnumeric
std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: _ArrayType=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> _ArrayType
std(a: _ArrayLikeComplex_co, axis: None=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> floating[Any]
std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None=..., dtype: _DTypeLike[_SCT]=..., out: None=..., ddof: float=..., keepdims: Literal[False]=..., *, where: _ArrayLikeBool_co=...) -> _SCT
std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: None=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any
std(a: _ArrayLikeComplex_co | _ArrayLikeObject_co, axis: None | _ShapeLike=..., dtype: DTypeLike=..., out: None=..., ddof: float=..., keepdims: bool=..., *, where: _ArrayLikeBool_co=...) -> Any
===========changed ref 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ stdSignif = float(
+ self.average
- stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
- print(f"The chi as a list is {self.chisAsaList[-1]}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ )
+ tempy = abs(
+ self.average
- print(f"std * chiSig {tempy}")
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.</s>
|
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
<3>:<del> print(f"The chi squared score is {result}")
<6>:<del> print(f"The dictionary checker score is {result2}")
|
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> print(f"The chi squared score is {result}")
<4> if result:
<5> result2 = self.dictionary.confirmlanguage(text, "English")
<6> print(f"The dictionary checker score is {result2}")
<7> if result2:
<8> return True
<9> else:
<10> return False
<11> else:
<12> return False
<13>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.chisquared.chiSquared
checkChi(text)
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
confirmlanguage(text, language)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ stdSignif = float(
+ self.average
- stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
- print(f"The chi as a list is {self.chisAsaList[-1]}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ )
+ tempy = abs(
+ self.average
- print(f"std * chiSig {tempy}")
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.</s>
===========changed ref 1===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
<s>
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
- print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
- print(float(self.chisAsaList[-1]) < stdSignif + 0.1)
- print(float(self.chisAsaList[-1]) > stdSignif - 0.1)
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
+ )
if (
+ self.chisAsaList[-1] <= abs(stdSignif)
- self.chisAsaList[-1]
- <= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
+ or self.totalEqual
- or self.totalEqual
+ #or float(self.chisAsaList[-1]) < stdSignif + 0.1
- or float(self.chisAsaList[-1]) < stdSignif + 0.1
+ #or float(self.chisAsaList[-1]) > stdSignif - 0.1
- or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
===========changed ref 2===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
"""Creates letter frequency of text and compares that to the letter frequency of the language"""
# if all items of the dictionary are the same, then it's a normal distribution
# examples of this could be "the quick brown fox jumped over the lazy dog"
letterFreq = self.getLetterFreq(text)
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
# so we dont have to calculate len more than once
# turns them into probabilities (frequency distribution)
lenOfString = len(text)
totalLetterFreq = 0.0
for key, value in letterFreq.items():
try:
letterFreq[key] = value / lenOfString
totalLetterFreq = totalLetterFreq + value
except ZeroDivisionError as e:
print(
'Error, you have entered an empty string :( The error is "'
+ str(e)
+ '" on line 34 of LanguageChecker.py (function chiSquared)'
)
exit(1)
# calculates chi squared of each language
maxChiSquare = 0.00
languagesChi = {}
for language in self.languages:
# , list(languages[language].values())
temp = self.myChi(letterFreq, self.languages[language])
languagesChi[language] = temp
if temp > maxChiSquare:
self.highestLanguage = language
maxChiSquare = temp
self.chisAsaList.append(maxChiSquare)
# calculates running average
self.oldAverage = self.average
self.totalDone += 1
# calculates a running average, maxChiSquare is the new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
</s>
===========changed ref 3===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
<s> new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
- print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
<0>:<del> print("hacking transposition")
<4>:<del> print(key)
<6>:<del> if key == 10:
<7>:<del> print(decryptedText)
<8>:<del> print("checking LC")
<10>:<del> print(result)
<12>:<del> print("*******************LC returns TRUE")
<23>:<add>
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> print("hacking transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> decryptedText = self.decryptMessage(key, message)
<4> print(key)
<5> # if decrypted english is found, return them
<6> if key == 10:
<7> print(decryptedText)
<8> print("checking LC")
<9> result = self.lc.checkLanguage(decryptedText)
<10> print(result)
<11> if result:
<12> print("*******************LC returns TRUE")
<13> exit(1)
<14> return {
<15> "lc": self.lc,
<16> "IsPlaintext?": True,
<17> "Plaintext": decryptedText,
<18> "Cipher": "Transposition",
<19> "Extra Information": f"The key is {key}",
<20> }
<21> if key == 11:
<22> import time
<23> time.sleep(60)
<24> exit(1)
<25> exit(1)
<26>
<27> # it is not found
<28> return {
<29> "lc": self.lc,
<30> "IsPlaintext?": False,
<31> "Plaintext": None,
<32> "Cipher": "Transposition",
<33> "Extra Information": None,
<34> }
<35>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: time
sleep(secs: float) -> None
===========changed ref 0===========
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
if text == "":
return False
result = self.chi.checkChi(text)
- print(f"The chi squared score is {result}")
if result:
result2 = self.dictionary.confirmlanguage(text, "English")
- print(f"The dictionary checker score is {result2}")
if result2:
return True
else:
return False
else:
return False
===========changed ref 1===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
"""Creates letter frequency of text and compares that to the letter frequency of the language"""
# if all items of the dictionary are the same, then it's a normal distribution
# examples of this could be "the quick brown fox jumped over the lazy dog"
letterFreq = self.getLetterFreq(text)
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
# so we dont have to calculate len more than once
# turns them into probabilities (frequency distribution)
lenOfString = len(text)
totalLetterFreq = 0.0
for key, value in letterFreq.items():
try:
letterFreq[key] = value / lenOfString
totalLetterFreq = totalLetterFreq + value
except ZeroDivisionError as e:
print(
'Error, you have entered an empty string :( The error is "'
+ str(e)
+ '" on line 34 of LanguageChecker.py (function chiSquared)'
)
exit(1)
# calculates chi squared of each language
maxChiSquare = 0.00
languagesChi = {}
for language in self.languages:
# , list(languages[language].values())
temp = self.myChi(letterFreq, self.languages[language])
languagesChi[language] = temp
if temp > maxChiSquare:
self.highestLanguage = language
maxChiSquare = temp
self.chisAsaList.append(maxChiSquare)
# calculates running average
self.oldAverage = self.average
self.totalDone += 1
# calculates a running average, maxChiSquare is the new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
</s>
===========changed ref 2===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
<s> new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
- print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
===========changed ref 3===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ stdSignif = float(
+ self.average
- stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
- print(f"The chi as a list is {self.chisAsaList[-1]}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ )
+ tempy = abs(
+ self.average
- print(f"std * chiSig {tempy}")
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.</s>
===========changed ref 4===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
# offset: 1
<s>
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- print(f"std - chiSig {(self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)}")
- print(self.chisAsaList[-1]<= abs(self.average- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)))
- print(float(self.chisAsaList[-1]) < stdSignif + 0.1)
- print(float(self.chisAsaList[-1]) > stdSignif - 0.1)
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
+ )
if (
+ self.chisAsaList[-1] <= abs(stdSignif)
- self.chisAsaList[-1]
- <= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
+ or self.totalEqual
- or self.totalEqual
+ #or float(self.chisAsaList[-1]) < stdSignif + 0.1
- or float(self.chisAsaList[-1]) < stdSignif + 0.1
+ #or float(self.chisAsaList[-1]) > stdSignif - 0.1
- or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
return True
else:
return False
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.__init__
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
<7>:<add> self.list_of_objects = [self.caesar, self.reverse, self.pig]
<del> self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.caesar = ca.Caesar(self.lc)
<2> self.reverse = re.Reverse(self.lc)
<3> self.viginere = vi.Viginere(self.lc)
<4> self.pig = pi.PigLatin(self.lc)
<5> self.trans = tr.Transposition(self.lc)
<6>
<7> self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
<8>
|
===========unchanged ref 0===========
at: Decryptor.basicEncryption.caesar
Caesar(lc)
at: Decryptor.basicEncryption.reverse
Reverse(lc)
at: Decryptor.basicEncryption.transposition
Transposition(lc)
at: Decryptor.basicEncryption.viginere
Viginere(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent.decrypt
self.lc = self.lc + answer["lc"]
at: ciphey.Decryptor.basicEncryption.pigLatin
PigLatin(lc)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
if text == "":
return False
result = self.chi.checkChi(text)
- print(f"The chi squared score is {result}")
if result:
result2 = self.dictionary.confirmlanguage(text, "English")
- print(f"The dictionary checker score is {result2}")
if result2:
return True
else:
return False
else:
return False
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
- print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
- print(key)
# if decrypted english is found, return them
- if key == 10:
- print(decryptedText)
- print("checking LC")
result = self.lc.checkLanguage(decryptedText)
- print(result)
if result:
- print("*******************LC returns TRUE")
exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
if key == 11:
import time
+
time.sleep(60)
exit(1)
exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 2===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
"""Creates letter frequency of text and compares that to the letter frequency of the language"""
# if all items of the dictionary are the same, then it's a normal distribution
# examples of this could be "the quick brown fox jumped over the lazy dog"
letterFreq = self.getLetterFreq(text)
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
# so we dont have to calculate len more than once
# turns them into probabilities (frequency distribution)
lenOfString = len(text)
totalLetterFreq = 0.0
for key, value in letterFreq.items():
try:
letterFreq[key] = value / lenOfString
totalLetterFreq = totalLetterFreq + value
except ZeroDivisionError as e:
print(
'Error, you have entered an empty string :( The error is "'
+ str(e)
+ '" on line 34 of LanguageChecker.py (function chiSquared)'
)
exit(1)
# calculates chi squared of each language
maxChiSquare = 0.00
languagesChi = {}
for language in self.languages:
# , list(languages[language].values())
temp = self.myChi(letterFreq, self.languages[language])
languagesChi[language] = temp
if temp > maxChiSquare:
self.highestLanguage = language
maxChiSquare = temp
self.chisAsaList.append(maxChiSquare)
# calculates running average
self.oldAverage = self.average
self.totalDone += 1
# calculates a running average, maxChiSquare is the new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
</s>
===========changed ref 3===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
<s> new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
- print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
===========changed ref 4===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
- if "CHARLES" in text.upper():
- print("************************************************************************************")
- print("************************************************************************************")
- print("************************************************************************************")
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# TODO 20% isn't optimal
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
+ stdSignif = float(
+ self.average
- stdSignif = float(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
- print(f"The chi as a list is {self.chisAsaList[-1]}")
+ - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
- tempy = abs(self.average - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold))
+ )
+ tempy = abs(
+ self.average
- print(f"std * chiSig {tempy}")
- print(f"Average is {self.average}")
+ - (self.oldstandarddeviation * self.</s>
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
88fb90187b1ed73363de3fc9e832b237312f949b
|
Fixing LC
|
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Hash.hashParent
HashParent()
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: mathsHelper
mathsHelper()
at: neuralNetworkMod.nn
NeuralNetwork()
===========changed ref 0===========
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
if text == "":
return False
result = self.chi.checkChi(text)
- print(f"The chi squared score is {result}")
if result:
result2 = self.dictionary.confirmlanguage(text, "English")
- print(f"The dictionary checker score is {result2}")
if result2:
return True
else:
return False
else:
return False
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
self.trans = tr.Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig]
- self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
- print("hacking transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
- print(key)
# if decrypted english is found, return them
- if key == 10:
- print(decryptedText)
- print("checking LC")
result = self.lc.checkLanguage(decryptedText)
- print(result)
if result:
- print("*******************LC returns TRUE")
exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
if key == 11:
import time
+
time.sleep(60)
exit(1)
exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 3===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
"""Creates letter frequency of text and compares that to the letter frequency of the language"""
# if all items of the dictionary are the same, then it's a normal distribution
# examples of this could be "the quick brown fox jumped over the lazy dog"
letterFreq = self.getLetterFreq(text)
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
# so we dont have to calculate len more than once
# turns them into probabilities (frequency distribution)
lenOfString = len(text)
totalLetterFreq = 0.0
for key, value in letterFreq.items():
try:
letterFreq[key] = value / lenOfString
totalLetterFreq = totalLetterFreq + value
except ZeroDivisionError as e:
print(
'Error, you have entered an empty string :( The error is "'
+ str(e)
+ '" on line 34 of LanguageChecker.py (function chiSquared)'
)
exit(1)
# calculates chi squared of each language
maxChiSquare = 0.00
languagesChi = {}
for language in self.languages:
# , list(languages[language].values())
temp = self.myChi(letterFreq, self.languages[language])
languagesChi[language] = temp
if temp > maxChiSquare:
self.highestLanguage = language
maxChiSquare = temp
self.chisAsaList.append(maxChiSquare)
# calculates running average
self.oldAverage = self.average
self.totalDone += 1
# calculates a running average, maxChiSquare is the new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
</s>
===========changed ref 4===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def chiSquared(self, text):
# offset: 1
<s> new chi score we get
self.average = (self.totalChi + maxChiSquare) / self.totalDone
- print(f"The chi squared score is {maxChiSquare}")
self.oldstandarddeviation = abs(self.standarddeviation)
self.standarddeviation = abs(std(self.chisAsaList))
return languagesChi
|
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
69d62ab398bf5c84530fbc7d68f7bc9a704b4251
|
Added top 1000 words checker
|
<3>:<add> if result or self.dictionary.check1000Words(text):
<del> if result:
|
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> if result:
<4> result2 = self.dictionary.confirmlanguage(text, "English")
<5> if result2:
<6> return True
<7> else:
<8> return False
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
check1000Words(text)
confirmlanguage(text, language)
at: languageCheckerMod.chisquared.chiSquared
checkChi(text)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
+
+ def check1000Words(self, text):
+ text = text.lower()
+ text = self.mh.stripPuncuation(text)
+ text = text.split(" ")
+ text = list(set(text))
+ # If any of the top 1000 words in the text appear
+ # return true
+ if any self.top1000Words in text:
+ return True
+ return False
+
===========changed ref 1===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
self.mh = mh.mathsHelper()
self.languagePercentage = 0.0
self.languageWordsCounter = 0.0
self.languageThreshold = 55
+ # this is hard coded because i dont want to use a library or rely on reading from files, as it's slow.
+ self.top1000Words = [
+ "able",
+ "about",
+ "above",
+ "act",
+ "add",
+ "afraid",
+ "after",
+ "again",
+ "against",
+ "age",
+ "ago",
+ "agree",
+ "air",
+ "all",
+ "allow",
+ "also",
+ "always",
+ "am",
+ "among",
+ "an",
+ "and",
+ "anger",
+ "animal",
+ "answer",
+ "any",
+ "appear",
+ "apple",
+ "are",
+ "area",
+ "arm",
+ "arrange",
+ "arrive",
+ "art",
+ "as",
+ "ask",
+ "at",
+ "atom",
+ "baby",
+ "back",
+ "bad",
+ "ball",
+ "band",
+ "bank",
+ "bar",
+ "base",
+ "basic",
+ "bat",
+ "be",
+ "bear",
+ "beat",
+ "beauty",
+ "bed",
+ "been",
+ "before",</s>
===========changed ref 2===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 1
<s>
+ "beauty",
+ "bed",
+ "been",
+ "before",
+ "began",
+ "begin",
+ "behind",
+ "believe",
+ "bell",
+ "best",
+ "better",
+ "between",
+ "big",
+ "bird",
+ "bit",
+ "black",
+ "block",
+ "blood",
+ "blow",
+ "blue",
+ "board",
+ "boat",
+ "body",
+ "bone",
+ "book",
+ "born",
+ "both",
+ "bottom",
+ "bought",
+ "box",
+ "boy",
+ "branch",
+ "bread",
+ "break",
+ "bright",
+ "bring",
+ "broad",
+ "broke",
+ "brother",
+ "brought",
+ "brown",
+ "build",
+ "burn",
+ "busy",
+ "but",
+ "buy",
+ "by",
+ "call",
+ "came",
+ "camp",
+ "can",
+ "capital",
+ "captain",
+ "car",
+ "card",
+ "care",
+ "carry",
+ "case",
</s>
===========changed ref 3===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 2
<s> "cat",
+ "catch",
+ "caught",
+ "cause",
+ "cell",
+ "cent",
+ "center",
+ "century",
+ "certain",
+ "chair",
+ "chance",
+ "change",
+ "character",
+ "charge",
+ "chart",
+ "check",
+ "chick",
+ "chief",
+ "child",
+ "children",
+ "choose",
+ "chord",
+ "circle",
+ "city",
+ "claim",
+ "class",
+ "clean",
+ "clear",
+ "climb",
+ "clock",
+ "close",
+ "clothe",
+ "cloud",
+ "coast",
+ "coat",
+ "cold",
+ "collect",
+ "colony",
+ "color",
+ "column",
+ "come",
+ "common",
+ "company",
+ "compare",
+ "complete",
+ "condition",
+ "connect",
+ "consider",
+ "consonant",
+ "contain",
+ "continent",
+ "continue",
+ "control",
+ "cook",
+ "cool",
+ "copy",
+ "corn",
+ "corner",
+ "correct",
+ "cost",
+ </s>
|
ciphey.languageCheckerMod.dictionaryChecker/dictionaryChecker.check1000Words
|
Modified
|
Ciphey~Ciphey
|
ced02b94614ff6103e1e45c79d7f9452ef2957b3
|
Done for the night
|
<0>:<add> check = dict.fromkeys(self.top1000Words)
<6>:<add> for word in text:
<add> print(word)
<add> if word in check:
<del> if any self.top1000Words in text:
<7>:<add> return True
<del> return True
<8>:<add> else:
<add> return False
<del> return False
|
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
<0> text = text.lower()
<1> text = self.mh.stripPuncuation(text)
<2> text = text.split(" ")
<3> text = list(set(text))
<4> # If any of the top 1000 words in the text appear
<5> # return true
<6> if any self.top1000Words in text:
<7> return True
<8> return False
<9>
|
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
self.mh = mh.mathsHelper()
self.languagePercentage = 0.0
self.languageWordsCounter = 0.0
self.languageThreshold = 55
# this is hard coded because i dont want to use a library or rely on reading from files, as it's slow.
- self.top1000Words = [
- "able",
- "about",
- "above",
- "act",
- "add",
- "afraid",
- "after",
- "again",
- "against",
- "age",
- "ago",
- "agree",
- "air",
- "all",
- "allow",
- "also",
- "always",
- "am",
- "among",
- "an",
- "and",
- "anger",
- "animal",
- "answer",
- "any",
- "appear",
- "apple",
- "are",
- "area",
- "arm",
- "arrange",
- "arrive",
- "art",
- "as",
- "ask",
- "at",
- "atom",
- "baby",
- "back",
- "bad",
- "ball",
- "band",
- "bank",
- "bar",
- "base",
- "basic",
- "bat",
- "be",
- "bear",
- "beat",
- "beauty",
- "bed",
- "been",
- "before",
</s>
===========changed ref 1===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 1
<s> <del> "beauty",
- "bed",
- "been",
- "before",
- "began",
- "begin",
- "behind",
- "believe",
- "bell",
- "best",
- "better",
- "between",
- "big",
- "bird",
- "bit",
- "black",
- "block",
- "blood",
- "blow",
- "blue",
- "board",
- "boat",
- "body",
- "bone",
- "book",
- "born",
- "both",
- "bottom",
- "bought",
- "box",
- "boy",
- "branch",
- "bread",
- "break",
- "bright",
- "bring",
- "broad",
- "broke",
- "brother",
- "brought",
- "brown",
- "build",
- "burn",
- "busy",
- "but",
- "buy",
- "by",
- "call",
- "came",
- "camp",
- "can",
- "capital",
- "captain",
- "car",
- "card",
- "care",
- "carry",
- "case",
- </s>
===========changed ref 2===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 2
<s>cat",
- "catch",
- "caught",
- "cause",
- "cell",
- "cent",
- "center",
- "century",
- "certain",
- "chair",
- "chance",
- "change",
- "character",
- "charge",
- "chart",
- "check",
- "chick",
- "chief",
- "child",
- "children",
- "choose",
- "chord",
- "circle",
- "city",
- "claim",
- "class",
- "clean",
- "clear",
- "climb",
- "clock",
- "close",
- "clothe",
- "cloud",
- "coast",
- "coat",
- "cold",
- "collect",
- "colony",
- "color",
- "column",
- "come",
- "common",
- "company",
- "compare",
- "complete",
- "condition",
- "connect",
- "consider",
- "consonant",
- "contain",
- "continent",
- "continue",
- "control",
- "cook",
- "cool",
- "copy",
- "corn",
- "corner",
- "correct",
- "cost",
- </s>
===========changed ref 3===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 3
<s>otton",
- "could",
- "count",
- "country",
- "course",
- "cover",
- "cow",
- "crease",
- "create",
- "crop",
- "cross",
- "crowd",
- "cry",
- "current",
- "cut",
- "dad",
- "dance",
- "danger",
- "dark",
- "day",
- "dead",
- "deal",
- "dear",
- "death",
- "decide",
- "decimal",
- "deep",
- "degree",
- "depend",
- "describe",
- "desert",
- "design",
- "determine",
- "develop",
- "dictionary",
- "did",
- "die",
- "differ",
- "difficult",
- "direct",
- "discuss",
- "distant",
- "divide",
- "division",
- "do",
- "doctor",
- "does",
- "dog",
- "dollar",
- "don't",
- "done",
- "door",
- "double",
- "down",
- "draw",
- "dream",
- "dress",
- "drink",
- "drive",
- </s>
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
ced02b94614ff6103e1e45c79d7f9452ef2957b3
|
Done for the night
|
<3>:<add> if result:
<del> if result or self.dictionary.check1000Words(text):
|
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> if result or self.dictionary.check1000Words(text):
<4> result2 = self.dictionary.confirmlanguage(text, "English")
<5> if result2:
<6> return True
<7> else:
<8> return False
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
confirmlanguage(text, language)
at: languageCheckerMod.chisquared.chiSquared
checkChi(text)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
+ check = dict.fromkeys(self.top1000Words)
text = text.lower()
text = self.mh.stripPuncuation(text)
text = text.split(" ")
text = list(set(text))
# If any of the top 1000 words in the text appear
# return true
+ for word in text:
+ print(word)
+ if word in check:
- if any self.top1000Words in text:
+ return True
- return True
+ else:
+ return False
- return False
===========changed ref 1===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
self.mh = mh.mathsHelper()
self.languagePercentage = 0.0
self.languageWordsCounter = 0.0
self.languageThreshold = 55
# this is hard coded because i dont want to use a library or rely on reading from files, as it's slow.
- self.top1000Words = [
- "able",
- "about",
- "above",
- "act",
- "add",
- "afraid",
- "after",
- "again",
- "against",
- "age",
- "ago",
- "agree",
- "air",
- "all",
- "allow",
- "also",
- "always",
- "am",
- "among",
- "an",
- "and",
- "anger",
- "animal",
- "answer",
- "any",
- "appear",
- "apple",
- "are",
- "area",
- "arm",
- "arrange",
- "arrive",
- "art",
- "as",
- "ask",
- "at",
- "atom",
- "baby",
- "back",
- "bad",
- "ball",
- "band",
- "bank",
- "bar",
- "base",
- "basic",
- "bat",
- "be",
- "bear",
- "beat",
- "beauty",
- "bed",
- "been",
- "before",
</s>
===========changed ref 2===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 1
<s> <del> "beauty",
- "bed",
- "been",
- "before",
- "began",
- "begin",
- "behind",
- "believe",
- "bell",
- "best",
- "better",
- "between",
- "big",
- "bird",
- "bit",
- "black",
- "block",
- "blood",
- "blow",
- "blue",
- "board",
- "boat",
- "body",
- "bone",
- "book",
- "born",
- "both",
- "bottom",
- "bought",
- "box",
- "boy",
- "branch",
- "bread",
- "break",
- "bright",
- "bring",
- "broad",
- "broke",
- "brother",
- "brought",
- "brown",
- "build",
- "burn",
- "busy",
- "but",
- "buy",
- "by",
- "call",
- "came",
- "camp",
- "can",
- "capital",
- "captain",
- "car",
- "card",
- "care",
- "carry",
- "case",
- </s>
===========changed ref 3===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def __init__(self):
# offset: 2
<s>cat",
- "catch",
- "caught",
- "cause",
- "cell",
- "cent",
- "center",
- "century",
- "certain",
- "chair",
- "chance",
- "change",
- "character",
- "charge",
- "chart",
- "check",
- "chick",
- "chief",
- "child",
- "children",
- "choose",
- "chord",
- "circle",
- "city",
- "claim",
- "class",
- "clean",
- "clear",
- "climb",
- "clock",
- "close",
- "clothe",
- "cloud",
- "coast",
- "coat",
- "cold",
- "collect",
- "colony",
- "color",
- "column",
- "come",
- "common",
- "company",
- "compare",
- "complete",
- "condition",
- "connect",
- "consider",
- "consonant",
- "contain",
- "continent",
- "continue",
- "control",
- "cook",
- "cool",
- "copy",
- "corn",
- "corner",
- "correct",
- "cost",
- </s>
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
527db3c81ea17895a27b4a96b581cea4c6835a8d
|
Trying to get check 1000 words to work
|
<3>:<add> if result or self.dictionary.check1000Words(text):
<del> if result:
|
# module: ciphey.languageCheckerMod.LanguageChecker
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> if result:
<4> result2 = self.dictionary.confirmlanguage(text, "English")
<5> if result2:
<6> return True
<7> else:
<8> return False
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
confirmlanguage(text, language)
at: languageCheckerMod.chisquared.chiSquared
checkChi(text)
at: languageCheckerMod.dictionaryChecker.dictionaryChecker
check1000Words(text)
|
ciphey.languageCheckerMod.dictionaryChecker/dictionaryChecker.check1000Words
|
Modified
|
Ciphey~Ciphey
|
168560d8e234901a97d68ad2d853de2f3fbe8fc9
|
Reducing lines of code
|
<1>:<del> text = text.lower()
<2>:<del> text = self.mh.stripPuncuation(text)
<3>:<del> text = text.split(" ")
<4>:<del> text = list(set(text))
<5>:<add> text = self.cleanText(text)
<8>:<del> print(word)
|
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
<0> check = dict.fromkeys(self.top1000Words)
<1> text = text.lower()
<2> text = self.mh.stripPuncuation(text)
<3> text = text.split(" ")
<4> text = list(set(text))
<5> # If any of the top 1000 words in the text appear
<6> # return true
<7> for word in text:
<8> print(word)
<9> if word in check:
<10> return True
<11> else:
<12> return False
<13>
|
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
+
+ def cleanText(self, text):
+ # makes the text unique words and readable
+ text = text.lower()
+ text = self.mh.stripPuncuation(text)
+ text = text.split(" ")
+ text = list(set(text))
+ return text
+
|
ciphey.languageCheckerMod.dictionaryChecker/dictionaryChecker.checkDictionary
|
Modified
|
Ciphey~Ciphey
|
168560d8e234901a97d68ad2d853de2f3fbe8fc9
|
Reducing lines of code
|
<4>:<del> text = text.lower()
<5>:<del> text = self.mh.stripPuncuation(text)
<6>:<del> text = text.split(" ")
<7>:<del> text = list(set(text)) # removes duplicate words
<8>:<add> text = self.cleanText(text)
|
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def checkDictionary(self, text, language):
<0> """Compares a word with
<1> The dictionary is sorted and the text is sorted"""
<2> # reads through most common words / passwords
<3> # and calculates how much of that is in language
<4> text = text.lower()
<5> text = self.mh.stripPuncuation(text)
<6> text = text.split(" ")
<7> text = list(set(text)) # removes duplicate words
<8> text.sort()
<9> # can dynamically use languages then
<10> language = str(language) + ".txt"
<11>
<12> # https://stackoverflow.com/questions/7165749/open-file-in-a-relative-location-in-python
<13> script_dir = os.path.dirname(__file__)
<14> file_path = os.path.join(script_dir, "English.txt")
<15> file = open(file_path, "r")
<16> f = file.readlines()
<17> file.close()
<18> f = [x.strip().lower() for x in f]
<19> # dictionary is "word\n" so I remove the "\n"
<20>
<21> # so this should loop until it gets to the point in the @staticmethod
<22> # that equals the word :)
<23>
<24> """
<25> for every single word in main dictionary
<26> if that word == text[0] then +1 to counter
<27> then +1 to text[0 + i]
<28> so say the dict is ordered
<29> we just loop through dict
<30> and eventually we'll reach a point where word in dict = word in text
<31> at that point, we move to the next text point
<32> both text and dict are sorted
<33> so we only loop once, we can do this in O(n log n) time
<34> """
<35> counter = 0
<36> counter_percent = 0</s>
|
===========below chunk 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def checkDictionary(self, text, language):
# offset: 1
for dictLengthCounter, word in enumerate(f):
# if there is more words counted than there is text
# it is 100%, sometimes it goes over
# so this stops that
if counter >= len(text):
break
# if the dictionary word is contained in the text somewhere
# counter + 1
if word in text:
counter = counter + 1
counter_percent = counter_percent + 1
self.languageWordsCounter = counter
self.languagePercentage = self.mh.percentage(
float(self.languageWordsCounter), float(len(text))
)
return counter
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker.__init__
self.mh = mh.mathsHelper()
self.languagePercentage = 0.0
self.languageWordsCounter = 0.0
at: ciphey.mathsHelper.mathsHelper
percentage(part, whole)
at: io.BufferedRandom
close(self) -> None
at: io.BufferedWriter
readlines(self, hint: int=..., /) -> List[bytes]
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
at: typing.IO
__slots__ = ()
close() -> None
readlines(hint: int=...) -> list[AnyStr]
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
+
+ def cleanText(self, text):
+ # makes the text unique words and readable
+ text = text.lower()
+ text = self.mh.stripPuncuation(text)
+ text = text.split(" ")
+ text = list(set(text))
+ return text
+
===========changed ref 1===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
check = dict.fromkeys(self.top1000Words)
- text = text.lower()
- text = self.mh.stripPuncuation(text)
- text = text.split(" ")
- text = list(set(text))
+ text = self.cleanText(text)
# If any of the top 1000 words in the text appear
# return true
for word in text:
- print(word)
if word in check:
return True
else:
return False
|
ciphey.test_integration/testIntegration.test_integration_charlesBabbage
|
Modified
|
Ciphey~Ciphey
|
191541bcee41a2a74746171f48485eaa4b11fb1f
|
Updated args
|
<2>:<add> Bug is that chi squared does not score this as True
<add> """
<del> """
|
# module: ciphey.test_integration
class testIntegration(unittest.TestCase):
def test_integration_charlesBabbage(self):
<0> """
<1> I had a bug with this exact string
<2> """
<3> text = """Charles Babbage, FRS (26 December 1791 - 18 October 1871) was an English mathematician, philosopher, inventor and mechanical engineer who originated the concept of a programmable computer. Considered a "father of the computer", Babbage is credited with inventing the first mechanical computer that eventually led to more complex designs. Parts of his uncompleted mechanisms are on display in the London Science Museum. In 1991, a perfectly functioning difference engine was constructed from Babbage's original plans. Built to tolerances achievable in the 19th century, the success of the finished engine indicated that Babbage's machine would have worked. Nine years later, the Science Museum completed the printer Babbage had designed for the difference engine."""
<4> lc = LanguageChecker.LanguageChecker()
<5> result = lc.checkLanguage(text)
<6> self.assertEqual(result, True)
<7>
|
===========unchanged ref 0===========
at: languageCheckerMod.LanguageChecker
LanguageChecker()
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
ab6a10c77ed42b222badbae0e0d2ee84df6f1776
|
Left exit(1) in transposition.py
|
<6>:<del> exit(1)
<14>:<del> if key == 11:
<15>:<del> import time
<16>:<del>
<17>:<del> time.sleep(60)
<18>:<del> exit(1)
<19>:<del> exit(1)
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> # brute-force by looping through every possible key
<1> for key in range(1, len(message)):
<2> decryptedText = self.decryptMessage(key, message)
<3> # if decrypted english is found, return them
<4> result = self.lc.checkLanguage(decryptedText)
<5> if result:
<6> exit(1)
<7> return {
<8> "lc": self.lc,
<9> "IsPlaintext?": True,
<10> "Plaintext": decryptedText,
<11> "Cipher": "Transposition",
<12> "Extra Information": f"The key is {key}",
<13> }
<14> if key == 11:
<15> import time
<16>
<17> time.sleep(60)
<18> exit(1)
<19> exit(1)
<20>
<21> # it is not found
<22> return {
<23> "lc": self.lc,
<24> "IsPlaintext?": False,
<25> "Plaintext": None,
<26> "Cipher": "Transposition",
<27> "Extra Information": None,
<28> }
<29>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
|
ciphey.Decryptor.basicEncryption.transposition/main
|
Modified
|
Ciphey~Ciphey
|
ab6a10c77ed42b222badbae0e0d2ee84df6f1776
|
Left exit(1) in transposition.py
|
# module: ciphey.Decryptor.basicEncryption.transposition
def main():
<0> # You might want to copy & paste this text from the source code at
<1> # http://invpy.com/transpositionHacker.py
<2> myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<3> x = Transposition("hello")
<4> hackedMessage = x.decrypt(myMessage)
<5>
<6> if hackedMessage == None:
<7> print("Failed to hack encryption.")
<8> </s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
def main():
# offset: 1
print("Copying hacked message to clipboard:")
print(hackedMessage)
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition
main()
at: ciphey.Decryptor.basicEncryption.transposition.main
hackedMessage = x.decrypt(myMessage)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
# brute-force by looping through every possible key
for key in range(1, len(message)):
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
if result:
- exit(1)
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
- if key == 11:
- import time
-
- time.sleep(60)
- exit(1)
- exit(1)
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
|
ciphey.Decryptor.Encoding.binary/Binary.decode
|
Modified
|
Ciphey~Ciphey
|
18c2ac6c89665ff040f2dee1d4c41f0bd11a095e
|
Fixing indention problems
|
<1>:<add> Decodes into binary using .encode()
<del> my own binary decoder lol ;p
|
# module: ciphey.Decryptor.Encoding.binary
class Binary:
def decode(self, text):
<0> """
<1> my own binary decoder lol ;p
<2> """
<3> text = text.replace(" ", "")
<4> # to a bytes string
<5> text = text.encode("utf-8")
<6>
<7> # into base 2
<8> n = int(text, 2)
<9>
<10> # into ascii
<11> text = n.to_bytes((n.bit_length() + 7) // 8, "big").decode()
<12>
<13> return text
<14>
| |
ciphey.__main__/Ciphey.decryptNormal
|
Modified
|
Ciphey~Ciphey
|
18c2ac6c89665ff040f2dee1d4c41f0bd11a095e
|
Fixing indention problems
|
<14>:<add> else:
<del> else:
|
# module: ciphey.__main__
class Ciphey:
def decryptNormal(self, bar=None):
<0> for key, val in self.whatToChoose.items():
<1> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<2> if not isinstance(key, str):
<3> key.setProbTable(val)
<4> ret = key.decrypt(self.text)
<5> if ret["IsPlaintext?"]:
<6> print(ret["Plaintext"])
<7> if self.cipher:
<8> if ret["Extra Information"] != None:
<9> print(
<10> "The cipher used is",
<11> ret["Cipher"] + ".",
<12> ret["Extra Information"] + ".",
<13> )
<14> else:
<15> print(ret["Cipher"])
<16> return ret
<17>
<18> if not self.greppable:
<19> bar()
<20>
<21> print("No encryption found. Here's the probabilities we calculated")
<22>
|
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent.EncodingParent
decrypt(text)
at: Decryptor.Hash.hashParent.HashParent
decrypt(text)
setProbTable(val)
at: Decryptor.basicEncryption.basic_parent.BasicParent
setProbTable(prob)
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent
setProbTable(table)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent
decrypt(text)
===========unchanged ref 1===========
at: ciphey.__main__.Ciphey.__init__
self.text = text
self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
self.greppable = grep
self.cipher = cipher
===========unchanged ref 2===========
at: ciphey.__main__.Ciphey.decrypt
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
self.whatToChoose = new_dict
at: collections.OrderedDict
update = __update = _collections_abc.MutableMapping.update
update = __update = _collections_abc.MutableMapping.update
items() -> _OrderedDictItemsView[_KT, _VT]
__ne__ = _collections_abc.MutableMapping.__ne__
__marker = object()
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.binary
class Binary:
def decode(self, text):
"""
+ Decodes into binary using .encode()
- my own binary decoder lol ;p
"""
text = text.replace(" ", "")
# to a bytes string
text = text.encode("utf-8")
# into base 2
n = int(text, 2)
# into ascii
text = n.to_bytes((n.bit_length() + 7) // 8, "big").decode()
return text
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
"""
this method calls 1 level of decrypt
The idea is that so long as decrypt doesnt return the plaintext
to carry on decrypting all subsets of the text until we find one that does decrypt properly
maybe only 2 levels
The way probability distribution works is something like this:
{Encoding: {"Binary": 0.137, "Base64": 0.09, "Hexadecimal": 0.00148}, Hashes: {"SHA1": 0.0906, "MD5": 0.98}}
If an item in the dictionary is == 0.00 then write it down as 0.001
Each parental dictiony object (eg encoding, hashing) is the actual object
So each decipherment class has a parent that controls all of it
sha1, sha256, md5, sha512 etc all belong to the object "hashes"
Ciphey passes each probability to these classes
Sort the dictionary
"""
self.probabilityDistribution = self.ai.predictnn(self.text)[0]
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
</s>
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
18c2ac6c89665ff040f2dee1d4c41f0bd11a095e
|
Fixing indention problems
|
<6>:<add> "-g",
<add> "--greppable",
<add> help="Only output the answer, no progress bars or information. Useful for grep",
<del> "-g", "--greppable", help="Only output the answer, no progress bars or information. Useful for grep", required=False
<7>:<add> required=False,
<32>:<del> print(
<33>:<add> print("No arguments were supplied. Look at the help menu with -h or --help")
<del> "No arguments were supplied. Look at the help menu with -h or --help"
<34>:<del> )
|
# module: ciphey.__main__
def main():
<0> parser = argparse.ArgumentParser(
<1> description="Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it."
<2> )
<3> # parser.add_argument('-f','--file', help='File you want to decrypt', required=False)
<4> # parser.add_argument('-l','--level', help='How many levels of decryption you want (the more levels, the slower it is)', required=False)
<5> parser.add_argument(
<6> "-g", "--greppable", help="Only output the answer, no progress bars or information. Useful for grep", required=False
<7> )
<8> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<9> # parser.add_argument('-s','--sicko-mode', help='If it is encrypted Ciphey WILL find it', required=False)
<10> parser.add_argument(
<11> "-c",
<12> "--printcipher",
<13> help="Do you want information on the cipher used?",
<14> required=False,
<15> )
<16>
<17> args = vars(parser.parse_args())
<18> if args["printcipher"] != None:
<19> cipher = True
<20> else:
<21> cipher = False
<22> if args["greppable"] != None:
<23> greppable = True
<24> else:
<25> greppable = False
<26>
<27> # uryyb zl sngure uryyb zl zbgure naq v ernyyl qb yvxr n tbbq ratyvfu oernxsnfg
<28> if args["text"]:
<29> cipherObj = Ciphey(args["text"], greppable, cipher)
<30> cipherObj.decrypt()
<31> else:
<32> print(
<33> "No arguments were supplied. Look at the help menu with -h or --help"
<34> )
</s>
|
===========unchanged ref 0===========
at: argparse
ArgumentParser(prog: Optional[str]=..., usage: Optional[str]=..., description: Optional[str]=..., epilog: Optional[str]=..., parents: Sequence[ArgumentParser]=..., formatter_class: _FormatterClass=..., prefix_chars: str=..., fromfile_prefix_chars: Optional[str]=..., argument_default: Any=..., conflict_handler: str=..., add_help: bool=..., allow_abbrev: bool=...)
at: argparse.ArgumentParser
parse_args(args: Optional[Sequence[Text]], namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]]=...) -> Namespace
parse_args(*, namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]], namespace: _N) -> _N
parse_args(*, namespace: _N) -> _N
at: argparse._ActionsContainer
add_argument(*name_or_flags: Text, action: Union[Text, Type[Action]]=..., nargs: Union[int, Text]=..., const: Any=..., default: Any=..., type: Union[Callable[[Text], _T], Callable[[str], _T], FileType]=..., choices: Iterable[_T]=..., required: bool=..., help: Optional[Text]=..., metavar: Optional[Union[Text, Tuple[Text, ...]]]=..., dest: Optional[Text]=..., version: Text=..., **kwargs: Any) -> Action
at: ciphey.__main__
Ciphey(text, grep=False, cipher=False)
at: ciphey.__main__.Ciphey
decrypt()
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
"""
this method calls 1 level of decrypt
The idea is that so long as decrypt doesnt return the plaintext
to carry on decrypting all subsets of the text until we find one that does decrypt properly
maybe only 2 levels
The way probability distribution works is something like this:
{Encoding: {"Binary": 0.137, "Base64": 0.09, "Hexadecimal": 0.00148}, Hashes: {"SHA1": 0.0906, "MD5": 0.98}}
If an item in the dictionary is == 0.00 then write it down as 0.001
Each parental dictiony object (eg encoding, hashing) is the actual object
So each decipherment class has a parent that controls all of it
sha1, sha256, md5, sha512 etc all belong to the object "hashes"
Ciphey passes each probability to these classes
Sort the dictionary
"""
self.probabilityDistribution = self.ai.predictnn(self.text)[0]
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
</s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 1
<s>": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
# sorts each indiviudal sub-dictionary
for key, value in self.whatToChoose.items():
for k, v in value.items():
if v < 0.01:
self.whatToChoose[key][k] = 0.01
for key, value in self.whatToChoose.items():
self.whatToChoose[key] = self.mh.sortDictionary(value)
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
"""
find key in the main dict, delete it
go through that dict and add each component to the end of this dict?
</s>
===========changed ref 2===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 2
<s>
temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
+ """
- """
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt", "w")
self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
===========changed ref 3===========
# module: ciphey.__main__
class Ciphey:
def decryptNormal(self, bar=None):
for key, val in self.whatToChoose.items():
# https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
if not isinstance(key, str):
key.setProbTable(val)
ret = key.decrypt(self.text)
if ret["IsPlaintext?"]:
print(ret["Plaintext"])
if self.cipher:
if ret["Extra Information"] != None:
print(
"The cipher used is",
ret["Cipher"] + ".",
ret["Extra Information"] + ".",
)
+ else:
- else:
print(ret["Cipher"])
return ret
if not self.greppable:
bar()
print("No encryption found. Here's the probabilities we calculated")
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
9212b2b94b10e81a229caf3d03428b3a480670c7
|
Added loggingGuru
|
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: Decryptor.Hash.hashParent
HashParent()
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: ciphey.mathsHelper
mathsHelper()
at: neuralNetworkMod.nn
NeuralNetwork()
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
- if __name__ == "__main__":
- main()
-
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
- def main():
- # You might want to copy & paste this text from the source code at
- # http://invpy.com/transpositionHacker.py
- myMessage = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
- x = Transposition("hello")
- hackedMessage = x.decrypt(myMessage)
-
- if hackedMessage == None:
- print("Failed to hack encryption.")
</s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
- def main():
# offset: 1
<s>.decrypt(myMessage)
-
- if hackedMessage == None:
- print("Failed to hack encryption.")
- else:
-
|
|
ciphey.mathsHelper/mathsHelper.sortDictionary
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<1>:<del>
<2>:<add> ret = dict(OrderedDict(sorted(dictionary.items())))
<del> return dict(OrderedDict(sorted(dictionary.items())))
<3>:<add> logger.debug(
<add> f"The old dictionary was {dictionary} and I am sorting it to {ret}"
<add> )
<add> return ret
|
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
<0> """Sorts a dictionary"""
<1>
<2> return dict(OrderedDict(sorted(dictionary.items())))
<3>
|
===========unchanged ref 0===========
at: collections
OrderedDict(map: Mapping[_KT, _VT], **kwargs: _VT)
OrderedDict(**kwargs: _VT)
OrderedDict(iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT)
|
ciphey.mathsHelper/mathsHelper.sortProbTable
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<29>:<add> logger.debug(f"The new sorted prob table is {d}")
|
# module: ciphey.mathsHelper
class mathsHelper:
def sortProbTable(self, probTable):
<0> """Sorts the probabiltiy table"""
<1> # for each object: prob table in dictionary
<2> maxOverall = 0
<3> maxDictPair = {}
<4> highestKey = None
<5>
<6> # sorts the prob table before we find max, and converts it to order dicts
<7> for key, value in probTable.items():
<8> probTable[key] = self.newSort(value)
<9> probTable[key] = dict(probTable[key])
<10>
<11> # gets maximum key then sets it to the front
<12> for key, value in probTable.items():
<13> maxLocal = 0
<14> # for each item in that table
<15> for key2, value2 in value.items():
<16> maxLocal = maxLocal + value2
<17> if maxLocal > maxOverall:
<18> # because the dict doesnt reset
<19> maxDictPair = {}
<20> maxOverall = maxLocal
<21> # so eventually, we get the maximum dict pairing?
<22> maxDictPair[key] = value
<23> highestKey = key
<24> # removes the highest key from the prob table
<25> del probTable[highestKey]
<26> # returns the max dict (at the start) with the prob table
<27> # this way, it should always work on most likely first.#
<28> d = {**maxDictPair, **probTable}
<29> return d
<30>
|
===========changed ref 0===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
|
ciphey.Decryptor.Encoding.ascii/Ascii.decrypt
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<0>:<add> logging.debug("Running ASCII decrypt")
<20>:<add> logging.debug(f"English found in ASCII, returning {result}")
|
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
<0> try:
<1> result = self.deascii(text)
<2> except ValueError as e:
<3> return {
<4> "lc": self.lc,
<5> "IsPlaintext?": False,
<6> "Plaintext": None,
<7> "Cipher": None,
<8> "Extra Information": None,
<9> }
<10> except TypeError as e:
<11> return {
<12> "lc": self.lc,
<13> "IsPlaintext?": False,
<14> "Plaintext": None,
<15> "Cipher": None,
<16> "Extra Information": None,
<17> }
<18>
<19> if self.lc.checkLanguage(result):
<20> return {
<21> "lc": self.lc,
<22> "IsPlaintext?": True,
<23> "Plaintext": result,
<24> "Cipher": "Ascii to Ascii number encoded",
<25> "Extra Information": None,
<26> }
<27>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.ascii.Ascii
deascii(text)
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
===========changed ref 1===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortProbTable(self, probTable):
"""Sorts the probabiltiy table"""
# for each object: prob table in dictionary
maxOverall = 0
maxDictPair = {}
highestKey = None
# sorts the prob table before we find max, and converts it to order dicts
for key, value in probTable.items():
probTable[key] = self.newSort(value)
probTable[key] = dict(probTable[key])
# gets maximum key then sets it to the front
for key, value in probTable.items():
maxLocal = 0
# for each item in that table
for key2, value2 in value.items():
maxLocal = maxLocal + value2
if maxLocal > maxOverall:
# because the dict doesnt reset
maxDictPair = {}
maxOverall = maxLocal
# so eventually, we get the maximum dict pairing?
maxDictPair[key] = value
highestKey = key
# removes the highest key from the prob table
del probTable[highestKey]
# returns the max dict (at the start) with the prob table
# this way, it should always work on most likely first.#
d = {**maxDictPair, **probTable}
+ logger.debug(f"The new sorted prob table is {d}")
return d
|
ciphey.Decryptor.Encoding.encodingParent/EncodingParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<2>:<add> logger.debug(f"Encoding parent is running {torun}")
<15>:<add> logger.debug(f"All answers are {answers}")
<18>:<add> logger.debug(f"Plaintext found {answer}")
|
# module: ciphey.Decryptor.Encoding.encodingParent
-
class EncodingParent:
def decrypt(self, text):
<0> self.text = text
<1> torun = [self.base64, self.binary, self.hex, self.ascii, self.morse]
<2> """
<3> ok so I have an array of functions
<4> and I want to apply each function to some text
<5> (text, function)
<6> but the way it works is you apply text to every item in the array (function)
<7>
<8> """
<9> from multiprocessing.dummy import Pool as ThreadPool
<10>
<11> pool = ThreadPool(4)
<12> answers = pool.map(self.callDecrypt, torun)
<13>
<14> for answer in answers:
<15> # adds the LC objects together
<16> self.lc = self.lc + answer["lc"]
<17> if answer["IsPlaintext?"]:
<18> return answer
<19> return {
<20> "lc": self.lc,
<21> "IsPlaintext?": False,
<22> "Plaintext": None,
<23> "Cipher": None,
<24> "Extra Information": None,
<25> }
<26>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent
callDecrypt(obj)
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent.__init__
self.lc = lc
self.base64 = Base64(self.lc)
self.binary = Binary(self.lc)
self.hex = Hexadecimal(self.lc)
self.ascii = Ascii(self.lc)
self.morse = MorseCode(self.lc)
at: multiprocessing.dummy
Pool(processes: Optional[int]=..., initializer: Optional[Callable[..., Any]]=..., initargs: Iterable[Any]=...) -> Any
===========changed ref 0===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
+ logging.debug("Running ASCII decrypt")
try:
result = self.deascii(text)
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
except TypeError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logging.debug(f"English found in ASCII, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Ascii number encoded",
"Extra Information": None,
}
===========changed ref 2===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortProbTable(self, probTable):
"""Sorts the probabiltiy table"""
# for each object: prob table in dictionary
maxOverall = 0
maxDictPair = {}
highestKey = None
# sorts the prob table before we find max, and converts it to order dicts
for key, value in probTable.items():
probTable[key] = self.newSort(value)
probTable[key] = dict(probTable[key])
# gets maximum key then sets it to the front
for key, value in probTable.items():
maxLocal = 0
# for each item in that table
for key2, value2 in value.items():
maxLocal = maxLocal + value2
if maxLocal > maxOverall:
# because the dict doesnt reset
maxDictPair = {}
maxOverall = maxLocal
# so eventually, we get the maximum dict pairing?
maxDictPair[key] = value
highestKey = key
# removes the highest key from the prob table
del probTable[highestKey]
# returns the max dict (at the start) with the prob table
# this way, it should always work on most likely first.#
d = {**maxDictPair, **probTable}
+ logger.debug(f"The new sorted prob table is {d}")
return d
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<7>:<add> # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<del> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<9>:<add> # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<del> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>:<add>
<del>
<11>:<add> # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<del> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>:<add>
<del>
<13>:<add> # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<del> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>:<add>
<del>
<15>:<add> # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<del> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
|
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: ciphey.mathsHelper
mathsHelper()
at: languageCheckerMod.LanguageChecker
LanguageChecker()
at: neuralNetworkMod.nn
NeuralNetwork()
at: sys
stderr: TextIO
===========changed ref 0===========
# module: ciphey.__main__
+
+ logger.add(
+ sys.stderr,
+ format="{time} {level} {message}",
+ filter="my_module",
+ level="DEBUG",
+ diagnose=True,
+ backtrace=True,
+ )
- logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="debug", diagnose=True, backtrace=True)
===========changed ref 1===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
+ logging.debug("Running ASCII decrypt")
try:
result = self.deascii(text)
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
except TypeError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logging.debug(f"English found in ASCII, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Ascii number encoded",
"Extra Information": None,
}
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.encodingParent
-
class EncodingParent:
def decrypt(self, text):
self.text = text
torun = [self.base64, self.binary, self.hex, self.ascii, self.morse]
+ logger.debug(f"Encoding parent is running {torun}")
"""
ok so I have an array of functions
and I want to apply each function to some text
(text, function)
but the way it works is you apply text to every item in the array (function)
"""
from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
answers = pool.map(self.callDecrypt, torun)
for answer in answers:
+ logger.debug(f"All answers are {answers}")
# adds the LC objects together
self.lc = self.lc + answer["lc"]
if answer["IsPlaintext?"]:
+ logger.debug(f"Plaintext found {answer}")
return answer
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
===========changed ref 4===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortProbTable(self, probTable):
"""Sorts the probabiltiy table"""
# for each object: prob table in dictionary
maxOverall = 0
maxDictPair = {}
highestKey = None
# sorts the prob table before we find max, and converts it to order dicts
for key, value in probTable.items():
probTable[key] = self.newSort(value)
probTable[key] = dict(probTable[key])
# gets maximum key then sets it to the front
for key, value in probTable.items():
maxLocal = 0
# for each item in that table
for key2, value2 in value.items():
maxLocal = maxLocal + value2
if maxLocal > maxOverall:
# because the dict doesnt reset
maxDictPair = {}
maxOverall = maxLocal
# so eventually, we get the maximum dict pairing?
maxDictPair[key] = value
highestKey = key
# removes the highest key from the prob table
del probTable[highestKey]
# returns the max dict (at the start) with the prob table
# this way, it should always work on most likely first.#
d = {**maxDictPair, **probTable}
+ logger.debug(f"The new sorted prob table is {d}")
return d
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<21>:<add> logger.debug(
<add> f"The probability table before 0.1 in __main__ is {self.whatToChoose}"
<del> logger.debug(f"The probability table before 0.1 in __main__ is {self.whatToChoose}")
<22>:<add> )
<28>:<add> logger.debug(
<add> f"The probability table after 0.1 in __main__ is {self.whatToChoose}"
<del> logger.debug(f"The probability table after 0.1 in __main__ is {self.whatToChoose}")
<29>:<add> )
|
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
<0> # Read the documentation for more on this function.
<1> self.probabilityDistribution = self.ai.predictnn(self.text)[0]
<2> self.whatToChoose = {
<3> self.hash: {
<4> "sha1": self.probabilityDistribution[0],
<5> "md5": self.probabilityDistribution[1],
<6> "sha256": self.probabilityDistribution[2],
<7> "sha512": self.probabilityDistribution[3],
<8> },
<9> self.basic: {"caesar": self.probabilityDistribution[4]},
<10> "plaintext": {"plaintext": self.probabilityDistribution[5]},
<11> self.encoding: {
<12> "reverse": self.probabilityDistribution[6],
<13> "base64": self.probabilityDistribution[7],
<14> "binary": self.probabilityDistribution[8],
<15> "hexadecimal": self.probabilityDistribution[9],
<16> "ascii": self.probabilityDistribution[10],
<17> "morse": self.probabilityDistribution[11],
<18> },
<19> }
<20>
<21> logger.debug(f"The probability table before 0.1 in __main__ is {self.whatToChoose}")
<22> # sorts each indiviudal sub-dictionary
<23> for key, value in self.whatToChoose.items():
<24> for k, v in value.items():
<25> # Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
<26> if v < 0.01:
<27> self.whatToChoose[key][k] = 0.01
<28> logger.debug(f"The probability table after 0.1 in __main__ is {self.whatToChoose}")
<29>
<30> for key, value in self.whatToChoose.items():
<31> self.whatToChoose[key] = self.mh.sortDictionary(value)
<32>
<33> self.what</s>
|
===========below chunk 0===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# offset: 1
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
logger.debug(f"The new probability table after sorting in __main__ is {self.whatToChoose}")
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt", "w")
self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.Decryptor.Hash.hashParent
HashParent()
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.text = text
at: collections.OrderedDict
update = __update = _collections_abc.MutableMapping.update
update = __update = _collections_abc.MutableMapping.update
items() -> _OrderedDictItemsView[_KT, _VT]
__ne__ = _collections_abc.MutableMapping.__ne__
__marker = object()
at: neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
===========changed ref 0===========
# module: ciphey.__main__
+
+ logger.add(
+ sys.stderr,
+ format="{time} {level} {message}",
+ filter="my_module",
+ level="DEBUG",
+ diagnose=True,
+ backtrace=True,
+ )
- logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="debug", diagnose=True, backtrace=True)
===========changed ref 1===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
===========changed ref 2===========
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# general purpose modules
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text = text
+ # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
- self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
+ # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
+
-
+ # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
+
-
+ # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
+
-
+ # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9et</s>
===========changed ref 3===========
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
<s> # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
- ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
+
-
+ # rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
- rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
+
-
+ # meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
- meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
+
-
+ # ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
- ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
+
-
+ # BRe bwlmprraio po droB wtinue r Pieno nc ay</s>
|
ciphey.__main__/Ciphey.one_level_of_decryption
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<2>:<add> logger.debug("__main__ is running as greppable")
<5>:<add> logger.debug("__main__ is running with progress bar")
|
# module: ciphey.__main__
+
class Ciphey:
def one_level_of_decryption(self, file=None, sickomode=None):
<0> items = range(1)
<1> if self.greppable:
<2> self.decryptNormal()
<3> else:
<4> with alive_bar() as bar:
<5> self.decryptNormal(bar)
<6>
|
===========changed ref 0===========
# module: ciphey.__main__
+
+ logger.add(
+ sys.stderr,
+ format="{time} {level} {message}",
+ filter="my_module",
+ level="DEBUG",
+ diagnose=True,
+ backtrace=True,
+ )
- logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="debug", diagnose=True, backtrace=True)
===========changed ref 1===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# Read the documentation for more on this function.
self.probabilityDistribution = self.ai.predictnn(self.text)[0]
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
+ logger.debug(
+ f"The probability table before 0.1 in __main__ is {self.whatToChoose}"
- logger.debug(f"The probability table before 0.1 in __main__ is {self.whatToChoose}")
+ )
# sorts each indiviudal sub-dictionary
for key, value in self.whatToChoose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
self.whatToChoose[key][k] = 0.01
+ logger.debug(
+ f"The probability table after 0.1 in __main__ is {self.whatToChoose}"
- logger.debug(f"The probability table after 0.1 in __main__ is {self.whatToChoose}")
+ )
</s>
===========changed ref 2===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# offset: 1
<s>"The probability table after 0.1 in __main__ is {self.whatToChoose}")
+ )
for key, value in self.whatToChoose.items():
self.whatToChoose[key] = self.mh.sortDictionary(value)
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
+ logger.debug(
+ f"The new probability table after sorting in __main__ is {self.whatToChoose}"
- logger.debug(f"The new probability table after sorting in __main__ is {self.whatToChoose}")
+ )
"""
</s>
===========changed ref 3===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# offset: 2
<s> each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt", "w")
self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
===========changed ref 4===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
===========changed ref 5===========
# module: ciphey.__main__
+
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# general purpose modules
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text = text
+ # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
- self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
+ # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
+
-
+ # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
+
-
+ # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
+
-
+ # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9et</s>
|
ciphey.__main__/Ciphey.decryptNormal
|
Modified
|
Ciphey~Ciphey
|
321d843d853225ad1d1670085e403a5b8a15e294
|
Adding more logging
|
<5>:<add> logger.debug(f"Decrypt normal in __main__ ret is {ret}")
<add> logger.debug(
<add> f"The plaintext is {ret['Plaintext']} and the extra information is {ret['Cipher']} and {ret['Extra Information']}"
<add> )
<add>
<20>:<add> logger.debug("No encryption found")
<del>
|
# module: ciphey.__main__
+
class Ciphey:
def decryptNormal(self, bar=None):
<0> for key, val in self.whatToChoose.items():
<1> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<2> if not isinstance(key, str):
<3> key.setProbTable(val)
<4> ret = key.decrypt(self.text)
<5> if ret["IsPlaintext?"]:
<6> print(ret["Plaintext"])
<7> if self.cipher:
<8> if ret["Extra Information"] != None:
<9> print(
<10> "The cipher used is",
<11> ret["Cipher"] + ".",
<12> ret["Extra Information"] + ".",
<13> )
<14> else:
<15> print(ret["Cipher"])
<16> return ret
<17>
<18> if not self.greppable:
<19> bar()
<20>
<21> print("No encryption found. Here's the probabilities we calculated")
<22>
|
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey.__init__
self.greppable = grep
===========changed ref 0===========
# module: ciphey.__main__
+
class Ciphey:
def one_level_of_decryption(self, file=None, sickomode=None):
items = range(1)
if self.greppable:
+ logger.debug("__main__ is running as greppable")
self.decryptNormal()
else:
with alive_bar() as bar:
+ logger.debug("__main__ is running with progress bar")
self.decryptNormal(bar)
===========changed ref 1===========
# module: ciphey.__main__
+
+ logger.add(
+ sys.stderr,
+ format="{time} {level} {message}",
+ filter="my_module",
+ level="DEBUG",
+ diagnose=True,
+ backtrace=True,
+ )
- logger.add(sys.stderr, format="{time} {level} {message}", filter="my_module", level="debug", diagnose=True, backtrace=True)
===========changed ref 2===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# Read the documentation for more on this function.
self.probabilityDistribution = self.ai.predictnn(self.text)[0]
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
+ logger.debug(
+ f"The probability table before 0.1 in __main__ is {self.whatToChoose}"
- logger.debug(f"The probability table before 0.1 in __main__ is {self.whatToChoose}")
+ )
# sorts each indiviudal sub-dictionary
for key, value in self.whatToChoose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
self.whatToChoose[key][k] = 0.01
+ logger.debug(
+ f"The probability table after 0.1 in __main__ is {self.whatToChoose}"
- logger.debug(f"The probability table after 0.1 in __main__ is {self.whatToChoose}")
+ )
</s>
===========changed ref 3===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# offset: 1
<s>"The probability table after 0.1 in __main__ is {self.whatToChoose}")
+ )
for key, value in self.whatToChoose.items():
self.whatToChoose[key] = self.mh.sortDictionary(value)
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
+ logger.debug(
+ f"The new probability table after sorting in __main__ is {self.whatToChoose}"
- logger.debug(f"The new probability table after sorting in __main__ is {self.whatToChoose}")
+ )
"""
</s>
===========changed ref 4===========
# module: ciphey.__main__
+
class Ciphey:
def decrypt(self):
# offset: 2
<s> each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt", "w")
self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
===========changed ref 5===========
# module: ciphey.mathsHelper
class mathsHelper:
def sortDictionary(self, dictionary):
"""Sorts a dictionary"""
-
+ ret = dict(OrderedDict(sorted(dictionary.items())))
- return dict(OrderedDict(sorted(dictionary.items())))
+ logger.debug(
+ f"The old dictionary was {dictionary} and I am sorting it to {ret}"
+ )
+ return ret
|
ciphey.Decryptor.Encoding.hexadecimal/Hexadecimal.decrypt
|
Modified
|
Ciphey~Ciphey
|
95a0fc2351146bb28dd96a51c437690990a9cb29
|
Adding more logging capabilities
|
<0>:<add> logging.debug("Attempting hexadecimal decryption")
<12>:<add> logging.debug(f"Hexadecimal successful, returning {result}")
|
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
<0> try:
<1> result = bytearray.fromhex(text).decode()
<2> except ValueError as e:
<3> return {
<4> "lc": self.lc,
<5> "IsPlaintext?": False,
<6> "Plaintext": None,
<7> "Cipher": None,
<8> "Extra Information": None,
<9> }
<10>
<11> if self.lc.checkLanguage(result):
<12> return {
<13> "lc": self.lc,
<14> "IsPlaintext?": True,
<15> "Plaintext": result,
<16> "Cipher": "Ascii to Hexadecimal encoded",
<17> "Extra Information": None,
<18> }
<19>
|
===========unchanged ref 0===========
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.Encoding.base64/Base64.decrypt
|
Modified
|
Ciphey~Ciphey
|
95a0fc2351146bb28dd96a51c437690990a9cb29
|
Adding more logging capabilities
|
<0>:<add> logging.debug("Attempting base decoding")
<4>:<add> logging.debug("Base64 decode attempt")
<14>:<add>
<del>
<16>:<add> logging.debug(f"Base64 successful, returning {result}")
<18>:<add> # Base32
<del> # Base32\
<19>:<add> logging.debug("attempting base32")
<31>:<add> logging.debug(f"base32 successful, {result}")
<34>:<add> logging.debug("Attempting base16")
<46>:<add> logging.debug(f"Base16 successful, {result}")
<49>:<add> logging.debug("Attempting base85")
|
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
<0> result = "None"
<1> ciph = "None"
<2>
<3> # try to decode, if it fails do nothing until the end
<4> try:
<5> result = base64.b64decode(text)
<6> # yeet turning b strings into normal stringy bois
<7> result = result.decode("utf-8")
<8> except UnicodeDecodeError as e:
<9> None
<10> except binascii.Error as e:
<11> None
<12> except ValueError:
<13> None
<14>
<15> if self.lc.checkLanguage(result):
<16> return self.goodRet(result, cipher="Base64")
<17>
<18> # Base32\
<19> try:
<20> result = base64.b32decode(text)
<21> # yeet turning b strings into normal stringy bois
<22> result = result.decode("utf-8")
<23> except UnicodeDecodeError as e:
<24> None
<25> except binascii.Error as e:
<26> None
<27> except ValueError:
<28> None
<29>
<30> if self.lc.checkLanguage(result):
<31> return self.goodRet(result, cipher="Base32")
<32>
<33> # Base16
<34> try:
<35> result = base64.b16decode(text)
<36> # yeet turning b strings into normal stringy bois
<37> result = result.decode("utf-8")
<38> except UnicodeDecodeError as e:
<39> None
<40> except binascii.Error as e:
<41> None
<42> except ValueError:
<43> None
<44>
<45> if self.lc.checkLanguage(result):
<46> return self.goodRet(result, cipher="Base16")
<47>
<48> # Base85
<49> try:
<50> result = base64.b85decode(text</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
# offset: 1
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
return self.goodRet(result, cipher="Base85")
# if nothing works, it has failed.
return self.badRet()
===========unchanged ref 0===========
at: base64
b64decode(s: _decodable, altchars: Optional[bytes]=..., validate: bool=...) -> bytes
b32decode(s: _decodable, casefold: bool=..., map01: Optional[bytes]=...) -> bytes
b16decode(s: _decodable, casefold: bool=...) -> bytes
b85decode(b: _decodable) -> bytes
at: binascii
Error(*args: object)
at: ciphey.Decryptor.Encoding.base64.Base64
goodRet(result, cipher)
at: ciphey.Decryptor.Encoding.base64.Base64.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
+ logging.debug("Attempting hexadecimal decryption")
try:
result = bytearray.fromhex(text).decode()
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logging.debug(f"Hexadecimal successful, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Hexadecimal encoded",
"Extra Information": None,
}
|
ciphey.Decryptor.Encoding.binary/Binary.decrypt
|
Modified
|
Ciphey~Ciphey
|
95a0fc2351146bb28dd96a51c437690990a9cb29
|
Adding more logging capabilities
|
<0>:<add> logger.debug("Attempting to decrypt binary")
<20>:<add> logger.debug(f"Answer found for binary, it's {return}")
|
# module: ciphey.Decryptor.Encoding.binary
-
class Binary:
def decrypt(self, text):
<0> try:
<1> result = self.decode(text)
<2> except ValueError as e:
<3> return {
<4> "lc": self.lc,
<5> "IsPlaintext?": False,
<6> "Plaintext": None,
<7> "Cipher": None,
<8> "Extra Information": None,
<9> }
<10> except TypeError as e:
<11> return {
<12> "lc": self.lc,
<13> "IsPlaintext?": False,
<14> "Plaintext": None,
<15> "Cipher": None,
<16> "Extra Information": None,
<17> }
<18>
<19> if self.lc.checkLanguage(result):
<20> return {
<21> "lc": self.lc,
<22> "IsPlaintext?": True,
<23> "Plaintext": result,
<24> "Cipher": "Ascii to Binary encoded",
<25> "Extra Information": None,
<26> }
<27> return {
<28> "lc": self.lc,
<29> "IsPlaintext?": False,
<30> "Plaintext": None,
<31> "Cipher": None,
<32> "Extra Information": None,
<33> }
<34>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.binary.Binary
decode(text)
at: ciphey.Decryptor.Encoding.binary.Binary.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
+ logging.debug("Attempting hexadecimal decryption")
try:
result = bytearray.fromhex(text).decode()
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logging.debug(f"Hexadecimal successful, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Hexadecimal encoded",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
+ logging.debug("Attempting base decoding")
result = "None"
ciph = "None"
# try to decode, if it fails do nothing until the end
+ logging.debug("Base64 decode attempt")
try:
result = base64.b64decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
+
-
if self.lc.checkLanguage(result):
+ logging.debug(f"Base64 successful, returning {result}")
return self.goodRet(result, cipher="Base64")
+ # Base32
- # Base32\
+ logging.debug("attempting base32")
try:
result = base64.b32decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"base32 successful, {result}")
return self.goodRet(result, cipher="Base32")
# Base16
+ logging.debug("Attempting base16")
try:
result = base64.b16decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self</s>
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
# offset: 1
<s>
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"Base16 successful, {result}")
return self.goodRet(result, cipher="Base16")
# Base85
+ logging.debug("Attempting base85")
try:
result = base64.b85decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"Base85 successful, {result}")
return self.goodRet(result, cipher="Base85")
# if nothing works, it has failed.
return self.badRet()
|
ciphey.Decryptor.Encoding.morsecode/MorseCode.decrypt
|
Modified
|
Ciphey~Ciphey
|
95a0fc2351146bb28dd96a51c437690990a9cb29
|
Adding more logging capabilities
|
<0>:<add> logging.debug("Attempting morse code")
<18>:<add> logging.debug(f"Morse code successful, returning {result}")
<del>
|
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def decrypt(self, text):
<0> if not self.checkIfMorse(text):
<1> return {
<2> "lc": self.lc,
<3> "IsPlaintext?": False,
<4> "Plaintext": None,
<5> "Cipher": "Morse Code",
<6> "Extra Information": None,
<7> }
<8> try:
<9> result = self.unmorse_it(text)
<10> except TypeError as e:
<11> return {
<12> "lc": self.lc,
<13> "IsPlaintext?": False,
<14> "Plaintext": None,
<15> "Cipher": "Morse Code",
<16> "Extra Information": None,
<17> }
<18>
<19> return {
<20> "lc": self.lc,
<21> "IsPlaintext?": True,
<22> "Plaintext": result,
<23> "Cipher": "Morse Code",
<24> "Extra Information": None,
<25> }
<26>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.morsecode.MorseCode
checkIfMorse(text)
unmorse_it(text)
at: ciphey.Decryptor.Encoding.morsecode.MorseCode.__init__
self.lc = lc
self.MORSE_CODE_DICT = {
"A": ".-",
"B": "-...",
"C": "-.-.",
"D": "-..",
"E": ".",
"F": "..-.",
"G": "--.",
"H": "....",
"I": "..",
"J": ".---",
"K": "-.-",
"L": ".-..",
"M": "--",
"N": "-.",
"O": "---",
"P": ".--.",
"Q": "--.-",
"R": ".-.",
"S": "...",
"T": "-",
"U": "..-",
"V": "...-",
"W": ".--",
"X": "-..-",
"Y": "-.--",
"Z": "--..",
"?": "..--..",
".": ".-.-.-",
" ": "/",
"0": "-----",
"1": ".----",
"2": "..---",
"3": "...--",
"4": "....-",
"5": ".....",
"6": "-....",
"7": "--...",
"8": "---..",
"9": "----.",
" ": "\n",
}
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
+ logging.debug("Attempting hexadecimal decryption")
try:
result = bytearray.fromhex(text).decode()
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logging.debug(f"Hexadecimal successful, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Hexadecimal encoded",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.binary
-
class Binary:
def decrypt(self, text):
+ logger.debug("Attempting to decrypt binary")
try:
result = self.decode(text)
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
except TypeError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logger.debug(f"Answer found for binary, it's {return}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Binary encoded",
"Extra Information": None,
}
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
+ logging.debug("Attempting base decoding")
result = "None"
ciph = "None"
# try to decode, if it fails do nothing until the end
+ logging.debug("Base64 decode attempt")
try:
result = base64.b64decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
+
-
if self.lc.checkLanguage(result):
+ logging.debug(f"Base64 successful, returning {result}")
return self.goodRet(result, cipher="Base64")
+ # Base32
- # Base32\
+ logging.debug("attempting base32")
try:
result = base64.b32decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"base32 successful, {result}")
return self.goodRet(result, cipher="Base32")
# Base16
+ logging.debug("Attempting base16")
try:
result = base64.b16decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self</s>
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.base64
-
class Base64:
def decrypt(self, text):
# offset: 1
<s>
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"Base16 successful, {result}")
return self.goodRet(result, cipher="Base16")
# Base85
+ logging.debug("Attempting base85")
try:
result = base64.b85decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logging.debug(f"Base85 successful, {result}")
return self.goodRet(result, cipher="Base85")
# if nothing works, it has failed.
return self.badRet()
|
ciphey.languageCheckerMod.chisquared/chiSquared.checkChi
|
Modified
|
Ciphey~Ciphey
|
a6b557489a0edc5f858481fc77da4bcc8adf8f25
|
Added more logging functionality to LC
|
<33>:<add> logger.debug(f"Chi squared returns true for {text}")
|
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
<0> """Checks to see if the Chi score is good
<1> if it is, it returns True
<2> Call this when you want to determine whether something is likely to be Chi or not
<3>
<4> Arguments:
<5> * text - the text you want to run a Chi Squared score on
<6>
<7> Outputs:
<8> * True - if it has a significantly lower chi squared score
<9> * False - if it doesn't have a significantly lower chi squared score
<10> """
<11> # runs after every chi squared to see if it's 1 significantly lower than averae
<12> # the or statement is bc if the program has just started I don't want it to ignore the
<13> # ones at the start
<14> self.chiSquared(text)
<15> # If the latest chi squared is less than the standard deviation
<16> # or if not many chi squares have been calculated
<17> # or if every single letter in a text appears exactly once (pangram)
<18> stdSignif = float(
<19> self.average
<20> - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
<21> )
<22> tempy = abs(
<23> self.average
<24> - (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
<25> )
<26> if (
<27> self.chisAsaList[-1] <= abs(stdSignif)
<28> or self.totalDone < self.totalDoneThreshold
<29> or self.totalEqual
<30> # or float(self.chisAsaList[-1]) < stdSignif + 0.1
<31> # or float(self.chisAsaList[-1]) > stdSignif - 0.1
<32> ):
<33> return True
<34> else:
<35> return False
<36>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.chisquared.chiSquared
chiSquared(text)
at: ciphey.languageCheckerMod.chisquared.chiSquared.__init__
self.average = 0.0
self.totalDone = 0.0
self.totalEqual = False
self.chisAsaList = []
self.chiSquaredSignificaneThreshold = 1 # how many stds you want to go below it
self.totalDoneThreshold = 10
self.oldstandarddeviation = 0.00
at: ciphey.languageCheckerMod.chisquared.chiSquared.chiSquared
self.totalEqual = self.mh.checkEqual(list(letterFreq.values()))
self.totalDone += 1
self.average = (self.totalChi + maxChiSquare) / self.totalDone
self.oldstandarddeviation = abs(self.standarddeviation)
|
ciphey.languageCheckerMod.dictionaryChecker/dictionaryChecker.check1000Words
|
Modified
|
Ciphey~Ciphey
|
a6b557489a0edc5f858481fc77da4bcc8adf8f25
|
Added more logging functionality to LC
|
<8>:<add> logger.debug(f"Check 1000 words returns True for word {word}")
|
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
<0> check = dict.fromkeys(self.top1000Words)
<1> text = self.cleanText(text)
<2> # If any of the top 1000 words in the text appear
<3> # return true
<4> for word in text:
<5> # I was debating using any() here, but I think they're the
<6> # same speed so it doesn't really matter too much
<7> if word in check:
<8> return True
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
cleanText(text)
===========unchanged ref 1===========
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker.__init__
self.top1000Words = {'able': None, 'about': None, 'above': None, 'act': None, 'add': None, 'afraid': None, 'after': None, 'again': None, 'against': None, 'age': None, 'ago': None, 'agree': None, 'air': None, 'all': None, 'allow': None, 'also': None, 'always': None, 'am': None, 'among': None, 'an': None, 'and': None, 'anger': None, 'animal': None, 'answer': None, 'any': None, 'appear': None, 'apple': None, 'are': None, 'area': None, 'arm': None, 'arrange': None, 'arrive': None, 'art': None, 'as': None, 'ask': None, 'at': None, 'atom': None, 'baby': None, 'back': None, 'bad': None, 'ball': None, 'band': None, 'bank': None, 'bar': None, 'base': None, 'basic': None, 'bat': None, 'be': None, 'bear': None, 'beat': None, 'beauty': None, 'bed': None, 'been': None, 'before': None, 'began': None, 'begin': None, 'behind': None, 'believe': None, 'bell': None, 'best': None, 'better': None, 'between': None, 'big': None, 'bird': None, 'bit': None, 'black': None, 'block': None, 'blood': None, 'blow': None, 'blue': None, 'board': None, 'boat': None, 'body': None, 'bone': None, 'book': None, 'born': None, 'both': None, 'bottom': None, 'bought': None, 'box': None, 'boy': None, 'branch': None, 'bread': None, 'break': None, 'bright': None, 'bring': None, 'broad': None, 'broke': None, 'brother': None, 'brought': None, 'b</s>
===========unchanged ref 2===========
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker.cleanText
text = list(set(text))
===========changed ref 0===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
stdSignif = float(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
tempy = abs(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
if (
self.chisAsaList[-1] <= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
or self.totalEqual
# or float(self.chisAsaList[-1]) < stdSignif + 0.1
# or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
+ logger.debug(f"Chi squared returns true for {text}")
return True
else:
return False
|
ciphey.languageCheckerMod.dictionaryChecker/dictionaryChecker.confirmlanguage
|
Modified
|
Ciphey~Ciphey
|
a6b557489a0edc5f858481fc77da4bcc8adf8f25
|
Added more logging functionality to LC
|
<2>:<add> logger.debug(f"The language percentange {self.languagePercentage} is over the threshold {self.languageThreshold}")
|
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def confirmlanguage(self, text, language):
<0> self.checkDictionary(text, language)
<1> if self.languagePercentage > self.languageThreshold:
<2> return True
<3> else:
<4> return False
<5>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
checkDictionary(text, language)
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker.__init__
self.languagePercentage = 0.0
self.languageThreshold = 55
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker.checkDictionary
counter = 0
counter = counter + 1
self.languagePercentage = self.mh.percentage(
float(self.languageWordsCounter), float(len(text))
)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
check = dict.fromkeys(self.top1000Words)
text = self.cleanText(text)
# If any of the top 1000 words in the text appear
# return true
for word in text:
# I was debating using any() here, but I think they're the
# same speed so it doesn't really matter too much
if word in check:
+ logger.debug(f"Check 1000 words returns True for word {word}")
return True
else:
return False
===========changed ref 1===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
stdSignif = float(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
tempy = abs(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
if (
self.chisAsaList[-1] <= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
or self.totalEqual
# or float(self.chisAsaList[-1]) < stdSignif + 0.1
# or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
+ logger.debug(f"Chi squared returns true for {text}")
return True
else:
return False
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
a6b557489a0edc5f858481fc77da4bcc8adf8f25
|
Added more logging functionality to LC
|
<3>:<add> wordsCheck = self.dictionary.check1000Words(text)
<del> if result or self.dictionary.check1000Words(text):
<4>:<add> if result or wordsCheck:
<add> logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
<5>:<add> logger.debug(f"Result is, dictionary checker, is {result2}")
|
# module: ciphey.languageCheckerMod.LanguageChecker
-
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> if result or self.dictionary.check1000Words(text):
<4> result2 = self.dictionary.confirmlanguage(text, "English")
<5> if result2:
<6> return True
<7> else:
<8> return False
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.chisquared.chiSquared
checkChi(text)
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
check1000Words(text)
confirmlanguage(text, language)
===========changed ref 0===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def confirmlanguage(self, text, language):
self.checkDictionary(text, language)
if self.languagePercentage > self.languageThreshold:
+ logger.debug(f"The language percentange {self.languagePercentage} is over the threshold {self.languageThreshold}")
return True
else:
return False
===========changed ref 1===========
# module: ciphey.languageCheckerMod.dictionaryChecker
class dictionaryChecker:
def check1000Words(self, text):
check = dict.fromkeys(self.top1000Words)
text = self.cleanText(text)
# If any of the top 1000 words in the text appear
# return true
for word in text:
# I was debating using any() here, but I think they're the
# same speed so it doesn't really matter too much
if word in check:
+ logger.debug(f"Check 1000 words returns True for word {word}")
return True
else:
return False
===========changed ref 2===========
# module: ciphey.languageCheckerMod.chisquared
class chiSquared:
def checkChi(self, text):
"""Checks to see if the Chi score is good
if it is, it returns True
Call this when you want to determine whether something is likely to be Chi or not
Arguments:
* text - the text you want to run a Chi Squared score on
Outputs:
* True - if it has a significantly lower chi squared score
* False - if it doesn't have a significantly lower chi squared score
"""
# runs after every chi squared to see if it's 1 significantly lower than averae
# the or statement is bc if the program has just started I don't want it to ignore the
# ones at the start
self.chiSquared(text)
# If the latest chi squared is less than the standard deviation
# or if not many chi squares have been calculated
# or if every single letter in a text appears exactly once (pangram)
stdSignif = float(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
tempy = abs(
self.average
- (self.oldstandarddeviation * self.chiSquaredSignificaneThreshold)
)
if (
self.chisAsaList[-1] <= abs(stdSignif)
or self.totalDone < self.totalDoneThreshold
or self.totalEqual
# or float(self.chisAsaList[-1]) < stdSignif + 0.1
# or float(self.chisAsaList[-1]) > stdSignif - 0.1
):
+ logger.debug(f"Chi squared returns true for {text}")
return True
else:
return False
|
ciphey.Decryptor.basicEncryption.pigLatin/PigLatin.decrypt
|
Modified
|
Ciphey~Ciphey
|
5393ba7fd7f3125c0f246eaa2265c9517ffbb004
|
All files should be logged now
|
<2>:<add> logger.debug("Trying pig latin")
|
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
<0> # If the message is less than or equal to 3 charecters, it's impossible to perform
<1> # a pig latin cipher on it unless the word was one letter long
<2> if len(message) <= 3:
<3> return {
<4> "lc": self.lc,
<5> "IsPlaintext?": False,
<6> "Plaintext": None,
<7> "Cipher": "Pig Latin",
<8> "Extra Information": None,
<9> }
<10>
<11> else:
<12> messagePIGWAY = message
<13>
<14> messagePIGAY = message[0 : len(message) - 2]
<15> # takes the last 2 letters of message
<16> message2AY = messagePIGAY[-1]
<17> # takes last letter of word and puts it into a variable
<18> messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
<19> # removes the last letter of the word
<20> message3AY = message2AY + messagePIGAY
<21> # creates a varaible which has the previous last letter as the first and
<22> # the rest of the word as the rest of it. This is one way to do Pig Latin.
<23>
<24> messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
<25> # takes the last 3 letters of message
<26> message2WAY = messagePIGWAY1
<27> # copies varaibles
<28> message2WAY = message2WAY[-1]
<29> # takes last letter of word and puts it into a variable
<30> messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
<31> # removes the last letter of the word
<32> messagepigWAY = message2WAY + messagePIGWAY1
<33> # creates a varaible which has the previous</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.pigLatin.PigLatin.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.basicEncryption.reverse/Reverse.decrypt
|
Modified
|
Ciphey~Ciphey
|
5393ba7fd7f3125c0f246eaa2265c9517ffbb004
|
All files should be logged now
|
<0>:<add> logger.debug("In reverse")
<5>:<add> logger.debug("Reverse returns True")
|
# module: ciphey.Decryptor.basicEncryption.reverse
-
class Reverse:
def decrypt(self, message):
<0> message = self.mh.stripPuncuation(message)
<1>
<2> message = message[::-1]
<3> result = self.lc.checkLanguage(message)
<4> if result:
<5> return {
<6> "lc": self.lc,
<7> "IsPlaintext?": True,
<8> "Plaintext": message,
<9> "Cipher": "Reverse",
<10> "Extra Information": None,
<11> }
<12> else:
<13> return {
<14> "lc": self.lc,
<15> "IsPlaintext?": False,
<16> "Plaintext": None,
<17> "Cipher": "Reverse",
<18> "Extra Information": None,
<19> }
<20>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.reverse.Reverse.__init__
self.lc = lc
self.mh = mh.mathsHelper()
at: mathsHelper.mathsHelper
stripPuncuation(text)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# If the message is less than or equal to 3 charecters, it's impossible to perform
# a pig latin cipher on it unless the word was one letter long
+ logger.debug("Trying pig latin")
if len(message) <= 3:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
messagePIGWAY = message
messagePIGAY = message[0 : len(message) - 2]
# takes the last 2 letters of message
message2AY = messagePIGAY[-1]
# takes last letter of word and puts it into a variable
messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
# removes the last letter of the word
message3AY = message2AY + messagePIGAY
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
# takes the last 3 letters of message
message2WAY = messagePIGWAY1
# copies varaibles
message2WAY = message2WAY[-1]
# takes last letter of word and puts it into a variable
messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
# removes the last letter of the word
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it.</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
<s> creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
+ logger.debug("Pig latin 3AY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
+ logger.debug("Pig latin WAY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
|
ciphey.Decryptor.basicEncryption.caesar/Caesar.decrypt
|
Modified
|
Ciphey~Ciphey
|
5393ba7fd7f3125c0f246eaa2265c9517ffbb004
|
All files should be logged now
|
<0>:<add> logger.debug("Trying caesar Cipher")
<29>:<add> logger.debug(f"Caesar cipher returns true {result}")
|
# module: ciphey.Decryptor.basicEncryption.caesar
-
class Caesar:
def decrypt(self, message):
<0> """ Simple python program to bruteforce a caesar cipher"""
<1>
<2> # Example string
<3> message = message.lower()
<4> # Everything we can encrypt
<5> SYMBOLS = "abcdefghijklmnopqrstuvwxyz"
<6>
<7> for counter, key in enumerate(range(len(SYMBOLS))):
<8> # try again with each key attempt
<9> translated = ""
<10>
<11> for character in message:
<12> if character in SYMBOLS:
<13> symbolIndex = SYMBOLS.find(character)
<14> translatedIndex = symbolIndex - key
<15>
<16> # In the event of wraparound
<17> if translatedIndex < 0:
<18> translatedIndex += len(SYMBOLS)
<19>
<20> translated += SYMBOLS[translatedIndex]
<21>
<22> else:
<23> # Append the symbol without encrypting or decrypting
<24> translated += character
<25>
<26> # Output each attempt
<27> result = self.lc.checkLanguage(translated)
<28> if result:
<29> return {
<30> "lc": self.lc,
<31> "IsPlaintext?": True,
<32> "Plaintext": translated,
<33> "Cipher": "Caesar",
<34> "Extra Information": f"The rotation used is {counter}",
<35> }
<36> # if none of them match English, return false!
<37> return {
<38> "lc": self.lc,
<39> "IsPlaintext?": False,
<40> "Plaintext": None,
<41> "Cipher": "Caesar",
<42> "Extra Information": None,
<43> }
<44>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.caesar.Caesar.__init__
self.lc = lc
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.reverse
-
class Reverse:
def decrypt(self, message):
+ logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
+ logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# If the message is less than or equal to 3 charecters, it's impossible to perform
# a pig latin cipher on it unless the word was one letter long
+ logger.debug("Trying pig latin")
if len(message) <= 3:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
messagePIGWAY = message
messagePIGAY = message[0 : len(message) - 2]
# takes the last 2 letters of message
message2AY = messagePIGAY[-1]
# takes last letter of word and puts it into a variable
messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
# removes the last letter of the word
message3AY = message2AY + messagePIGAY
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
# takes the last 3 letters of message
message2WAY = messagePIGWAY1
# copies varaibles
message2WAY = message2WAY[-1]
# takes last letter of word and puts it into a variable
messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
# removes the last letter of the word
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it.</s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
<s> creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
+ logger.debug("Pig latin 3AY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
+ logger.debug("Pig latin WAY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
|
ciphey.Decryptor.Encoding.base64/Base64.decrypt
|
Modified
|
Ciphey~Ciphey
|
b3ca61348adebb351039fc183665268839591a63
|
Fixed a bug in binary where Logger was misspellt as Logging
|
<0>:<add> logger.debug("Attempting base decoding")
<del> logging.debug("Attempting base decoding")
<5>:<add> logger.debug("Base64 decode attempt")
<del> logging.debug("Base64 decode attempt")
<18>:<add> logger.debug(f"Base64 successful, returning {result}")
<del> logging.debug(f"Base64 successful, returning {result}")
<22>:<add> logger.debug("attempting base32")
<del> logging.debug("attempting base32")
<35>:<add> logger.debug(f"base32 successful, {result}")
<del> logging.debug(f"base32 successful, {result}")
<39>:<add> logger.debug("Attempting base16")
<del> logging.debug("Attempting base16")
|
# module: ciphey.Decryptor.Encoding.base64
class Base64:
def decrypt(self, text):
<0> logging.debug("Attempting base decoding")
<1> result = "None"
<2> ciph = "None"
<3>
<4> # try to decode, if it fails do nothing until the end
<5> logging.debug("Base64 decode attempt")
<6> try:
<7> result = base64.b64decode(text)
<8> # yeet turning b strings into normal stringy bois
<9> result = result.decode("utf-8")
<10> except UnicodeDecodeError as e:
<11> None
<12> except binascii.Error as e:
<13> None
<14> except ValueError:
<15> None
<16>
<17> if self.lc.checkLanguage(result):
<18> logging.debug(f"Base64 successful, returning {result}")
<19> return self.goodRet(result, cipher="Base64")
<20>
<21> # Base32
<22> logging.debug("attempting base32")
<23> try:
<24> result = base64.b32decode(text)
<25> # yeet turning b strings into normal stringy bois
<26> result = result.decode("utf-8")
<27> except UnicodeDecodeError as e:
<28> None
<29> except binascii.Error as e:
<30> None
<31> except ValueError:
<32> None
<33>
<34> if self.lc.checkLanguage(result):
<35> logging.debug(f"base32 successful, {result}")
<36> return self.goodRet(result, cipher="Base32")
<37>
<38> # Base16
<39> logging.debug("Attempting base16")
<40> try:
<41> result = base64.b16decode(text)
<42> # yeet turning b strings into normal stringy bois
<43> result = result.decode("utf-8")
<44> except UnicodeDecodeError as e:
<45> None
<46> except binascii.</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Encoding.base64
class Base64:
def decrypt(self, text):
# offset: 1
None
except ValueError:
None
if self.lc.checkLanguage(result):
logging.debug(f"Base16 successful, {result}")
return self.goodRet(result, cipher="Base16")
# Base85
logging.debug("Attempting base85")
try:
result = base64.b85decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
logging.debug(f"Base85 successful, {result}")
return self.goodRet(result, cipher="Base85")
# if nothing works, it has failed.
return self.badRet()
===========unchanged ref 0===========
at: base64
b64decode(s: _decodable, altchars: Optional[bytes]=..., validate: bool=...) -> bytes
b32decode(s: _decodable, casefold: bool=..., map01: Optional[bytes]=...) -> bytes
b16decode(s: _decodable, casefold: bool=...) -> bytes
b85decode(b: _decodable) -> bytes
at: binascii
Error(*args: object)
at: ciphey.Decryptor.Encoding.base64.Base64
goodRet(result, cipher)
badRet()
at: ciphey.Decryptor.Encoding.base64.Base64.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.Encoding.binary/Binary.decrypt
|
Modified
|
Ciphey~Ciphey
|
b3ca61348adebb351039fc183665268839591a63
|
Fixed a bug in binary where Logger was misspellt as Logging
|
<21>:<add> logger.debug(f"Answer found for binary")
<del> logger.debug(f"Answer found for binary, it's {return}")
|
# module: ciphey.Decryptor.Encoding.binary
class Binary:
def decrypt(self, text):
<0> logger.debug("Attempting to decrypt binary")
<1> try:
<2> result = self.decode(text)
<3> except ValueError as e:
<4> return {
<5> "lc": self.lc,
<6> "IsPlaintext?": False,
<7> "Plaintext": None,
<8> "Cipher": None,
<9> "Extra Information": None,
<10> }
<11> except TypeError as e:
<12> return {
<13> "lc": self.lc,
<14> "IsPlaintext?": False,
<15> "Plaintext": None,
<16> "Cipher": None,
<17> "Extra Information": None,
<18> }
<19>
<20> if self.lc.checkLanguage(result):
<21> logger.debug(f"Answer found for binary, it's {return}")
<22> return {
<23> "lc": self.lc,
<24> "IsPlaintext?": True,
<25> "Plaintext": result,
<26> "Cipher": "Ascii to Binary encoded",
<27> "Extra Information": None,
<28> }
<29> return {
<30> "lc": self.lc,
<31> "IsPlaintext?": False,
<32> "Plaintext": None,
<33> "Cipher": None,
<34> "Extra Information": None,
<35> }
<36>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.binary.Binary
decode(text)
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.base64
class Base64:
def decrypt(self, text):
+ logger.debug("Attempting base decoding")
- logging.debug("Attempting base decoding")
result = "None"
ciph = "None"
# try to decode, if it fails do nothing until the end
+ logger.debug("Base64 decode attempt")
- logging.debug("Base64 decode attempt")
try:
result = base64.b64decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logger.debug(f"Base64 successful, returning {result}")
- logging.debug(f"Base64 successful, returning {result}")
return self.goodRet(result, cipher="Base64")
# Base32
+ logger.debug("attempting base32")
- logging.debug("attempting base32")
try:
result = base64.b32decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logger.debug(f"base32 successful, {result}")
- logging.debug(f"base32 successful, {result}")
return self.goodRet(result, cipher="Base32")
# Base16
+ logger.debug("Attempting base16")
- logging.debug("Attempting base16")
try:
result = base64.b16decode(text)
</s>
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.base64
class Base64:
def decrypt(self, text):
# offset: 1
<s> <del> logging.debug("Attempting base16")
try:
result = base64.b16decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logger.debug(f"Base16 successful, {result}")
- logging.debug(f"Base16 successful, {result}")
return self.goodRet(result, cipher="Base16")
# Base85
+ logger.debug("Attempting base85")
- logging.debug("Attempting base85")
try:
result = base64.b85decode(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
None
except binascii.Error as e:
None
except ValueError:
None
if self.lc.checkLanguage(result):
+ logger.debug(f"Base85 successful, {result}")
- logging.debug(f"Base85 successful, {result}")
return self.goodRet(result, cipher="Base85")
# if nothing works, it has failed.
return self.badRet()
|
ciphey.Decryptor.Encoding.hexadecimal/Hexadecimal.decrypt
|
Modified
|
Ciphey~Ciphey
|
bfcd92f0729845112c5997a06c0c02387901eb20
|
Logging bug fixes
|
<0>:<add> logger.debug("Attempting hexadecimal decryption")
<del> logging.debug("Attempting hexadecimal decryption")
<13>:<add> logger.debug(f"Hexadecimal successful, returning {result}")
<del> logging.debug(f"Hexadecimal successful, returning {result}")
|
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
<0> logging.debug("Attempting hexadecimal decryption")
<1> try:
<2> result = bytearray.fromhex(text).decode()
<3> except ValueError as e:
<4> return {
<5> "lc": self.lc,
<6> "IsPlaintext?": False,
<7> "Plaintext": None,
<8> "Cipher": None,
<9> "Extra Information": None,
<10> }
<11>
<12> if self.lc.checkLanguage(result):
<13> logging.debug(f"Hexadecimal successful, returning {result}")
<14> return {
<15> "lc": self.lc,
<16> "IsPlaintext?": True,
<17> "Plaintext": result,
<18> "Cipher": "Ascii to Hexadecimal encoded",
<19> "Extra Information": None,
<20> }
<21>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.hexadecimal.Hexadecimal.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.Encoding.ascii/Ascii.decrypt
|
Modified
|
Ciphey~Ciphey
|
bfcd92f0729845112c5997a06c0c02387901eb20
|
Logging bug fixes
|
<0>:<add> logger.debug("Running ASCII decrypt")
<del> logging.debug("Running ASCII decrypt")
<21>:<add> logger.debug(f"English found in ASCII, returning {result}")
<del> logging.debug(f"English found in ASCII, returning {result}")
|
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
<0> logging.debug("Running ASCII decrypt")
<1> try:
<2> result = self.deascii(text)
<3> except ValueError as e:
<4> return {
<5> "lc": self.lc,
<6> "IsPlaintext?": False,
<7> "Plaintext": None,
<8> "Cipher": None,
<9> "Extra Information": None,
<10> }
<11> except TypeError as e:
<12> return {
<13> "lc": self.lc,
<14> "IsPlaintext?": False,
<15> "Plaintext": None,
<16> "Cipher": None,
<17> "Extra Information": None,
<18> }
<19>
<20> if self.lc.checkLanguage(result):
<21> logging.debug(f"English found in ASCII, returning {result}")
<22> return {
<23> "lc": self.lc,
<24> "IsPlaintext?": True,
<25> "Plaintext": result,
<26> "Cipher": "Ascii to Ascii number encoded",
<27> "Extra Information": None,
<28> }
<29>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.ascii.Ascii
deascii(text)
at: ciphey.Decryptor.Encoding.ascii.Ascii.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
+ logger.debug("Attempting hexadecimal decryption")
- logging.debug("Attempting hexadecimal decryption")
try:
result = bytearray.fromhex(text).decode()
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logger.debug(f"Hexadecimal successful, returning {result}")
- logging.debug(f"Hexadecimal successful, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Hexadecimal encoded",
"Extra Information": None,
}
|
ciphey.Decryptor.Encoding.morsecode/MorseCode.decrypt
|
Modified
|
Ciphey~Ciphey
|
bfcd92f0729845112c5997a06c0c02387901eb20
|
Logging bug fixes
|
<0>:<add> logger.debug("Attempting morse code")
<del> logging.debug("Attempting morse code")
<19>:<add> logger.debug(f"Morse code successful, returning {result}")
<del> logging.debug(f"Morse code successful, returning {result}")
|
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def decrypt(self, text):
<0> logging.debug("Attempting morse code")
<1> if not self.checkIfMorse(text):
<2> return {
<3> "lc": self.lc,
<4> "IsPlaintext?": False,
<5> "Plaintext": None,
<6> "Cipher": "Morse Code",
<7> "Extra Information": None,
<8> }
<9> try:
<10> result = self.unmorse_it(text)
<11> except TypeError as e:
<12> return {
<13> "lc": self.lc,
<14> "IsPlaintext?": False,
<15> "Plaintext": None,
<16> "Cipher": "Morse Code",
<17> "Extra Information": None,
<18> }
<19> logging.debug(f"Morse code successful, returning {result}")
<20> return {
<21> "lc": self.lc,
<22> "IsPlaintext?": True,
<23> "Plaintext": result,
<24> "Cipher": "Morse Code",
<25> "Extra Information": None,
<26> }
<27>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.morsecode.MorseCode
checkIfMorse(text)
unmorse_it(text)
at: ciphey.Decryptor.Encoding.morsecode.MorseCode.__init__
self.lc = lc
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.hexadecimal
class Hexadecimal:
def decrypt(self, text):
+ logger.debug("Attempting hexadecimal decryption")
- logging.debug("Attempting hexadecimal decryption")
try:
result = bytearray.fromhex(text).decode()
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logger.debug(f"Hexadecimal successful, returning {result}")
- logging.debug(f"Hexadecimal successful, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Hexadecimal encoded",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
+ logger.debug("Running ASCII decrypt")
- logging.debug("Running ASCII decrypt")
try:
result = self.deascii(text)
except ValueError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
except TypeError as e:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": None,
}
if self.lc.checkLanguage(result):
+ logger.debug(f"English found in ASCII, returning {result}")
- logging.debug(f"English found in ASCII, returning {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": result,
"Cipher": "Ascii to Ascii number encoded",
"Extra Information": None,
}
|
countCode/countlines
|
Modified
|
Ciphey~Ciphey
|
399f3d1681ffd36f30dced83d67801dd59865d93
|
Fixed code counter
|
<18>:<add> print('{:>10} |{:>10} | {:<20}'.format(newlines, lines, reldir_of_thing))
<del> print('{:>10} |{:>10} | {:<20}'.format(2
<19>:<del> newlines, lines, reldir_of_thing))
|
# module: countCode
def countlines(start, lines=0, header=True, begin_start=None):
<0> if header:
<1> print('{:>10} |{:>10} | {:<20}'.format('ADDED', 'TOTAL', 'FILE'))
<2> print('{:->11}|{:->11}|{:->20}'.format('', '', ''))
<3>
<4> for thing in os.listdir(start):
<5> thing = os.path.join(start, thing)
<6> if os.path.isfile(thing):
<7> if thing.endswith('.py'):
<8> with open(thing, 'r') as f:
<9> newlines = f.readlines()
<10> newlines = len(newlines)
<11> lines += newlines
<12>
<13> if begin_start is not None:
<14> reldir_of_thing = '.' + thing.replace(begin_start, '')
<15> else:
<16> reldir_of_thing = '.' + thing.replace(start, '')
<17>
<18> print('{:>10} |{:>10} | {:<20}'.format(2
<19> newlines, lines, reldir_of_thing))
<20>
<21>
<22> for thing in os.listdir(start):
<23> thing = os.path.join(start, thing)
<24> if os.path.isdir(thing):
<25> lines = countlines(thing, lines, header=False, begin_start=start)
<26>
<27> return lines
<28>
|
===========unchanged ref 0===========
at: io.BufferedRandom
readlines(self, hint: int=..., /) -> List[bytes]
at: os
listdir(path: bytes) -> List[bytes]
listdir(path: int) -> List[str]
listdir(path: Optional[str]=...) -> List[str]
listdir(path: _PathLike[str]) -> List[str]
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
at: typing.IO
__slots__ = ()
readlines(hint: int=...) -> list[AnyStr]
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
4de11ab8392e8c7b754311e2b89bbce07b29c0b6
|
Fixing logger bugs
|
<0>:<add> logger.debug("Entering transposition")
<2>:<add> logger.debug(f"Transposition trying key {key}")
<6>:<add> logger.debug("transposition returns true")
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> # brute-force by looping through every possible key
<1> for key in range(1, len(message)):
<2> decryptedText = self.decryptMessage(key, message)
<3> # if decrypted english is found, return them
<4> result = self.lc.checkLanguage(decryptedText)
<5> if result:
<6> return {
<7> "lc": self.lc,
<8> "IsPlaintext?": True,
<9> "Plaintext": decryptedText,
<10> "Cipher": "Transposition",
<11> "Extra Information": f"The key is {key}",
<12> }
<13>
<14> # it is not found
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": False,
<18> "Plaintext": None,
<19> "Cipher": "Transposition",
<20> "Extra Information": None,
<21> }
<22>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(self, key, message)
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decryptMessage
|
Modified
|
Ciphey~Ciphey
|
4de11ab8392e8c7b754311e2b89bbce07b29c0b6
|
Fixing logger bugs
|
<0>:<add> logger.debug("Decrypting message in transposition")
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decryptMessage(self, key, message):
<0> # The transposition decrypt function will simulate the "columns" and
<1> # "rows" of the grid that the plaintext is written on by using a list
<2> # of strings. First, we need to calculate a few values.
<3>
<4> # The number of "columns" in our transposition grid:
<5> numOfColumns = math.ceil(len(message) / key)
<6> # The number of "rows" in our grid will need:
<7> numOfRows = key
<8> # The number of "shaded boxes" in the last "column" of the grid:
<9> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<10>
<11> # Each string in plaintext represents a column in the grid.
<12> plaintext = [""] * numOfColumns
<13>
<14> # The col and row variables point to where in the grid the next
<15> # character in the encrypted message will go.
<16> col = 0
<17> row = 0
<18>
<19> for symbol in message:
<20> plaintext[col] += symbol
<21> col += 1 # point to next column
<22>
<23> # If there are no more columns OR we're at a shaded box, go back to
<24> # the first column and the next row.
<25> if (col == numOfColumns) or (
<26> col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
<27> ):
<28> col = 0
<29> row += 1
<30>
<31> return "".join(plaintext)
<32>
|
===========unchanged ref 0===========
at: math
ceil(x: SupportsFloat, /) -> int
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
+ logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
+ logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
if result:
+ logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
4de11ab8392e8c7b754311e2b89bbce07b29c0b6
|
Fixing logger bugs
|
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> # rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> # meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> # ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
<22>
<23> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
-
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
# -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Hash.hashParent
HashParent()
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.mathsHelper
mathsHelper()
at: languageCheckerMod.LanguageChecker
LanguageChecker()
at: neuralNetworkMod.nn
NeuralNetwork()
===========changed ref 0===========
# module: ciphey.__main__
logger.add(
sys.stderr,
format="{time} {level} {message}",
filter="my_module",
level="DEBUG",
diagnose=True,
backtrace=True,
)
+ # removes the logger
+ logger.remove()
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
+ logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
+ logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
if result:
+ logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decryptMessage(self, key, message):
+ logger.debug("Decrypting message in transposition")
# The transposition decrypt function will simulate the "columns" and
# "rows" of the grid that the plaintext is written on by using a list
# of strings. First, we need to calculate a few values.
# The number of "columns" in our transposition grid:
numOfColumns = math.ceil(len(message) / key)
# The number of "rows" in our grid will need:
numOfRows = key
# The number of "shaded boxes" in the last "column" of the grid:
numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
# Each string in plaintext represents a column in the grid.
plaintext = [""] * numOfColumns
# The col and row variables point to where in the grid the next
# character in the encrypted message will go.
col = 0
row = 0
for symbol in message:
plaintext[col] += symbol
col += 1 # point to next column
# If there are no more columns OR we're at a shaded box, go back to
# the first column and the next row.
if (col == numOfColumns) or (
col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
):
col = 0
row += 1
return "".join(plaintext)
|
|
ciphey.Decryptor.basicEncryption.reverse/Reverse.decrypt
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<15>:<add> logger.debug(f"Reverse returns False")
|
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
<0> logger.debug("In reverse")
<1> message = self.mh.stripPuncuation(message)
<2>
<3> message = message[::-1]
<4> result = self.lc.checkLanguage(message)
<5> if result:
<6> logger.debug("Reverse returns True")
<7> return {
<8> "lc": self.lc,
<9> "IsPlaintext?": True,
<10> "Plaintext": message,
<11> "Cipher": "Reverse",
<12> "Extra Information": None,
<13> }
<14> else:
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": False,
<18> "Plaintext": None,
<19> "Cipher": "Reverse",
<20> "Extra Information": None,
<21> }
<22>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.reverse.Reverse.__init__
self.lc = lc
self.mh = mh.mathsHelper()
at: ciphey.mathsHelper.mathsHelper
stripPuncuation(text)
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
|
ciphey.Decryptor.basicEncryption.pigLatin/PigLatin.decrypt
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<4>:<add> logger.debug(f"Pig Latin is less than 3 so returning false")
|
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
<0> # If the message is less than or equal to 3 charecters, it's impossible to perform
<1> # a pig latin cipher on it unless the word was one letter long
<2> logger.debug("Trying pig latin")
<3> if len(message) <= 3:
<4> return {
<5> "lc": self.lc,
<6> "IsPlaintext?": False,
<7> "Plaintext": None,
<8> "Cipher": "Pig Latin",
<9> "Extra Information": None,
<10> }
<11>
<12> else:
<13> messagePIGWAY = message
<14>
<15> messagePIGAY = message[0 : len(message) - 2]
<16> # takes the last 2 letters of message
<17> message2AY = messagePIGAY[-1]
<18> # takes last letter of word and puts it into a variable
<19> messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
<20> # removes the last letter of the word
<21> message3AY = message2AY + messagePIGAY
<22> # creates a varaible which has the previous last letter as the first and
<23> # the rest of the word as the rest of it. This is one way to do Pig Latin.
<24>
<25> messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
<26> # takes the last 3 letters of message
<27> message2WAY = messagePIGWAY1
<28> # copies varaibles
<29> message2WAY = message2WAY[-1]
<30> # takes last letter of word and puts it into a variable
<31> messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
<32> # removes the last letter of the word
<33> messagepigWAY = message2WAY + messagePIGWAY1
</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
logger.debug("Pig latin 3AY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
logger.debug("Pig latin WAY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.pigLatin.PigLatin.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
+ logger.debug(f"Reverse returns False")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
|
ciphey.languageCheckerMod.LanguageChecker/LanguageChecker.checkLanguage
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<0>:<add> logger.debug(f"In Language Checker with {text}")
<5>:<add> logger.debug(
<add> f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}"
<del> logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
<6>:<add> )
<11>:<add> logger.debug(f"Phase 2 returns false")
<13>:<add> logger.debug(f"phase 1 returns false")
|
# module: ciphey.languageCheckerMod.LanguageChecker
+
class LanguageChecker:
def checkLanguage(self, text):
<0> if text == "":
<1> return False
<2> result = self.chi.checkChi(text)
<3> wordsCheck = self.dictionary.check1000Words(text)
<4> if result or wordsCheck:
<5> logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
<6> result2 = self.dictionary.confirmlanguage(text, "English")
<7> logger.debug(f"Result is, dictionary checker, is {result2}")
<8> if result2:
<9> return True
<10> else:
<11> return False
<12> else:
<13> return False
<14>
|
===========unchanged ref 0===========
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__add__
self.chi = new
at: ciphey.languageCheckerMod.LanguageChecker.LanguageChecker.__init__
self.dictionary = dc.dictionaryChecker()
self.chi = cs.chiSquared()
at: ciphey.languageCheckerMod.chisquared.chiSquared
checkChi(text)
at: ciphey.languageCheckerMod.dictionaryChecker.dictionaryChecker
check1000Words(text)
at: languageCheckerMod.dictionaryChecker.dictionaryChecker
confirmlanguage(text, language)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
+ logger.debug(f"Reverse returns False")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# If the message is less than or equal to 3 charecters, it's impossible to perform
# a pig latin cipher on it unless the word was one letter long
logger.debug("Trying pig latin")
if len(message) <= 3:
+ logger.debug(f"Pig Latin is less than 3 so returning false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
messagePIGWAY = message
messagePIGAY = message[0 : len(message) - 2]
# takes the last 2 letters of message
message2AY = messagePIGAY[-1]
# takes last letter of word and puts it into a variable
messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
# removes the last letter of the word
message3AY = message2AY + messagePIGAY
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
# takes the last 3 letters of message
message2WAY = messagePIGWAY1
# copies varaibles
message2WAY = message2WAY[-1]
# takes last letter of word and puts it into a variable
messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
# removes the last letter of the word
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous</s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
<s>
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
logger.debug("Pig latin 3AY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
logger.debug("Pig latin WAY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
+ logger.debug(f"Pig Latin returns false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
|
ciphey.Decryptor.basicEncryption.caesar/Caesar.decrypt
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<39>:<add> logger.debug(f"Caesar cipher returns false")
|
# module: ciphey.Decryptor.basicEncryption.caesar
class Caesar:
def decrypt(self, message):
<0> logger.debug("Trying caesar Cipher")
<1> """ Simple python program to bruteforce a caesar cipher"""
<2>
<3> # Example string
<4> message = message.lower()
<5> # Everything we can encrypt
<6> SYMBOLS = "abcdefghijklmnopqrstuvwxyz"
<7>
<8> for counter, key in enumerate(range(len(SYMBOLS))):
<9> # try again with each key attempt
<10> translated = ""
<11>
<12> for character in message:
<13> if character in SYMBOLS:
<14> symbolIndex = SYMBOLS.find(character)
<15> translatedIndex = symbolIndex - key
<16>
<17> # In the event of wraparound
<18> if translatedIndex < 0:
<19> translatedIndex += len(SYMBOLS)
<20>
<21> translated += SYMBOLS[translatedIndex]
<22>
<23> else:
<24> # Append the symbol without encrypting or decrypting
<25> translated += character
<26>
<27> # Output each attempt
<28> result = self.lc.checkLanguage(translated)
<29> if result:
<30> logger.debug(f"Caesar cipher returns true {result}")
<31> return {
<32> "lc": self.lc,
<33> "IsPlaintext?": True,
<34> "Plaintext": translated,
<35> "Cipher": "Caesar",
<36> "Extra Information": f"The rotation used is {counter}",
<37> }
<38> # if none of them match English, return false!
<39> return {
<40> "lc": self.lc,
<41> "IsPlaintext?": False,
<42> "Plaintext": None,
<43> "Cipher": "Caesar",
<44> "Extra Information": None,
<45> }
<46>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.caesar.Caesar.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
+ logger.debug(f"Reverse returns False")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.languageCheckerMod.LanguageChecker
+
class LanguageChecker:
def checkLanguage(self, text):
+ logger.debug(f"In Language Checker with {text}")
if text == "":
return False
result = self.chi.checkChi(text)
wordsCheck = self.dictionary.check1000Words(text)
if result or wordsCheck:
+ logger.debug(
+ f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}"
- logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
+ )
result2 = self.dictionary.confirmlanguage(text, "English")
logger.debug(f"Result is, dictionary checker, is {result2}")
if result2:
return True
else:
+ logger.debug(f"Phase 2 returns false")
return False
else:
+ logger.debug(f"phase 1 returns false")
return False
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# If the message is less than or equal to 3 charecters, it's impossible to perform
# a pig latin cipher on it unless the word was one letter long
logger.debug("Trying pig latin")
if len(message) <= 3:
+ logger.debug(f"Pig Latin is less than 3 so returning false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
messagePIGWAY = message
messagePIGAY = message[0 : len(message) - 2]
# takes the last 2 letters of message
message2AY = messagePIGAY[-1]
# takes last letter of word and puts it into a variable
messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
# removes the last letter of the word
message3AY = message2AY + messagePIGAY
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
# takes the last 3 letters of message
message2WAY = messagePIGWAY1
# copies varaibles
message2WAY = message2WAY[-1]
# takes last letter of word and puts it into a variable
messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
# removes the last letter of the word
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous</s>
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
<s>
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
# TODO find a way to return 2 variables
# this returns 2 variables in a tuple
if self.lc.checkLanguage(message3AY):
logger.debug("Pig latin 3AY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message3AY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
elif self.lc.checkLanguage(messagepigWAY):
logger.debug("Pig latin WAY returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": messagepigWAY,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
+ logger.debug(f"Pig Latin returns false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.__init__
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<7>:<add> # self.list_of_objects = [self.caesar, self.reverse, self.pig]
<del> self.list_of_objects = [self.caesar, self.reverse, self.pig]
<8>:<add> self.list_of_objects = [self.trans]
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.caesar = ca.Caesar(self.lc)
<2> self.reverse = re.Reverse(self.lc)
<3> self.viginere = vi.Viginere(self.lc)
<4> self.pig = pi.PigLatin(self.lc)
<5> self.trans = tr.Transposition(self.lc)
<6>
<7> self.list_of_objects = [self.caesar, self.reverse, self.pig]
<8>
|
===========unchanged ref 0===========
at: Decryptor.basicEncryption.pigLatin
PigLatin(lc)
at: Decryptor.basicEncryption.viginere
Viginere(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent.decrypt
self.lc = self.lc + answer["lc"]
at: ciphey.Decryptor.basicEncryption.caesar
Caesar(lc)
at: ciphey.Decryptor.basicEncryption.reverse
Reverse(lc)
at: ciphey.Decryptor.basicEncryption.transposition
Transposition(lc)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
+ logger.debug(f"Reverse returns False")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.languageCheckerMod.LanguageChecker
+
class LanguageChecker:
def checkLanguage(self, text):
+ logger.debug(f"In Language Checker with {text}")
if text == "":
return False
result = self.chi.checkChi(text)
wordsCheck = self.dictionary.check1000Words(text)
if result or wordsCheck:
+ logger.debug(
+ f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}"
- logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
+ )
result2 = self.dictionary.confirmlanguage(text, "English")
logger.debug(f"Result is, dictionary checker, is {result2}")
if result2:
return True
else:
+ logger.debug(f"Phase 2 returns false")
return False
else:
+ logger.debug(f"phase 1 returns false")
return False
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.caesar
class Caesar:
def decrypt(self, message):
logger.debug("Trying caesar Cipher")
""" Simple python program to bruteforce a caesar cipher"""
# Example string
message = message.lower()
# Everything we can encrypt
SYMBOLS = "abcdefghijklmnopqrstuvwxyz"
for counter, key in enumerate(range(len(SYMBOLS))):
# try again with each key attempt
translated = ""
for character in message:
if character in SYMBOLS:
symbolIndex = SYMBOLS.find(character)
translatedIndex = symbolIndex - key
# In the event of wraparound
if translatedIndex < 0:
translatedIndex += len(SYMBOLS)
translated += SYMBOLS[translatedIndex]
else:
# Append the symbol without encrypting or decrypting
translated += character
# Output each attempt
result = self.lc.checkLanguage(translated)
if result:
logger.debug(f"Caesar cipher returns true {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": translated,
"Cipher": "Caesar",
"Extra Information": f"The rotation used is {counter}",
}
# if none of them match English, return false!
+ logger.debug(f"Caesar cipher returns false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Caesar",
"Extra Information": None,
}
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# If the message is less than or equal to 3 charecters, it's impossible to perform
# a pig latin cipher on it unless the word was one letter long
logger.debug("Trying pig latin")
if len(message) <= 3:
+ logger.debug(f"Pig Latin is less than 3 so returning false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Pig Latin",
"Extra Information": None,
}
else:
messagePIGWAY = message
messagePIGAY = message[0 : len(message) - 2]
# takes the last 2 letters of message
message2AY = messagePIGAY[-1]
# takes last letter of word and puts it into a variable
messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
# removes the last letter of the word
message3AY = message2AY + messagePIGAY
# creates a varaible which has the previous last letter as the first and
# the rest of the word as the rest of it. This is one way to do Pig Latin.
messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
# takes the last 3 letters of message
message2WAY = messagePIGWAY1
# copies varaibles
message2WAY = message2WAY[-1]
# takes last letter of word and puts it into a variable
messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
# removes the last letter of the word
messagepigWAY = message2WAY + messagePIGWAY1
# creates a varaible which has the previous</s>
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
79310d71a7c5d162988b27a6c8d5929798b5952a
|
I have no idea why transposition doesnt work
|
<7>:<add> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<del> # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<9>:<add> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<del> # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<11>:<add> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<del> # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<13>:<add> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<del> # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<15>:<add> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<del> # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<17>:<add> rteoh add e,D7c1Etnpnee
|
# module: ciphey.__main__
+ # removes the logger
+ # logger.remove()
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> # self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> # ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> # oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> # edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> # ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> # rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> # meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> # ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw</s>
|
===========below chunk 0===========
# module: ciphey.__main__
+ # removes the logger
+ # logger.remove()
class Ciphey:
def __init__(self, text, grep=False, cipher=False):
# offset: 1
# BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
# -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.Decryptor.Hash.hashParent
HashParent()
at: ciphey.Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: ciphey.mathsHelper
mathsHelper()
at: ciphey.neuralNetworkMod.nn
NeuralNetwork()
===========changed ref 0===========
# module: ciphey.__main__
logger.add(
sys.stderr,
format="{time} {level} {message}",
filter="my_module",
level="DEBUG",
diagnose=True,
backtrace=True,
)
- # removes the logger
- logger.remove()
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
self.trans = tr.Transposition(self.lc)
+ # self.list_of_objects = [self.caesar, self.reverse, self.pig]
- self.list_of_objects = [self.caesar, self.reverse, self.pig]
+ self.list_of_objects = [self.trans]
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.reverse
class Reverse:
def decrypt(self, message):
logger.debug("In reverse")
message = self.mh.stripPuncuation(message)
message = message[::-1]
result = self.lc.checkLanguage(message)
if result:
logger.debug("Reverse returns True")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": message,
"Cipher": "Reverse",
"Extra Information": None,
}
else:
+ logger.debug(f"Reverse returns False")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Reverse",
"Extra Information": None,
}
===========changed ref 3===========
# module: ciphey.languageCheckerMod.LanguageChecker
+
class LanguageChecker:
def checkLanguage(self, text):
+ logger.debug(f"In Language Checker with {text}")
if text == "":
return False
result = self.chi.checkChi(text)
wordsCheck = self.dictionary.check1000Words(text)
if result or wordsCheck:
+ logger.debug(
+ f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}"
- logger.debug(f"Phase 1 complete. Result is {result} and 1000 words is {wordsCheck}")
+ )
result2 = self.dictionary.confirmlanguage(text, "English")
logger.debug(f"Result is, dictionary checker, is {result2}")
if result2:
return True
else:
+ logger.debug(f"Phase 2 returns false")
return False
else:
+ logger.debug(f"phase 1 returns false")
return False
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.caesar
class Caesar:
def decrypt(self, message):
logger.debug("Trying caesar Cipher")
""" Simple python program to bruteforce a caesar cipher"""
# Example string
message = message.lower()
# Everything we can encrypt
SYMBOLS = "abcdefghijklmnopqrstuvwxyz"
for counter, key in enumerate(range(len(SYMBOLS))):
# try again with each key attempt
translated = ""
for character in message:
if character in SYMBOLS:
symbolIndex = SYMBOLS.find(character)
translatedIndex = symbolIndex - key
# In the event of wraparound
if translatedIndex < 0:
translatedIndex += len(SYMBOLS)
translated += SYMBOLS[translatedIndex]
else:
# Append the symbol without encrypting or decrypting
translated += character
# Output each attempt
result = self.lc.checkLanguage(translated)
if result:
logger.debug(f"Caesar cipher returns true {result}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": translated,
"Cipher": "Caesar",
"Extra Information": f"The rotation used is {counter}",
}
# if none of them match English, return false!
+ logger.debug(f"Caesar cipher returns false")
return {
"lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Caesar",
"Extra Information": None,
}
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
92a11e64c09b5bb95a5abeff18143013f91108bc
|
Transposition kinda works integrated
|
<1>:<add> text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
<add> na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
<add> euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
<add> one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
<add> ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
<add> gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
<add> aBercaeu thllnrshicwsg etriebruaisss d iorr."""
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<2>
<3> decryptedText = self.hackTransposition(text)
<4> return decryptedText
<5>
| |
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
92a11e64c09b5bb95a5abeff18143013f91108bc
|
Transposition kinda works integrated
|
<7>:<add> if key == 6:
<add> logger.debug(f"KEY 6 HAS BEEN REACHED")
<add> result = True
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> logger.debug("Entering transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> logger.debug(f"Transposition trying key {key}")
<4> decryptedText = self.decryptMessage(key, message)
<5> # if decrypted english is found, return them
<6> result = self.lc.checkLanguage(decryptedText)
<7> if result:
<8> logger.debug("transposition returns true")
<9> return {
<10> "lc": self.lc,
<11> "IsPlaintext?": True,
<12> "Plaintext": decryptedText,
<13> "Cipher": "Transposition",
<14> "Extra Information": f"The key is {key}",
<15> }
<16>
<17> # it is not found
<18> return {
<19> "lc": self.lc,
<20> "IsPlaintext?": False,
<21> "Plaintext": None,
<22> "Cipher": "Transposition",
<23> "Extra Information": None,
<24> }
<25>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
decryptMessage(key, message)
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.decrypt
text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
aBercaeu thllnrshicwsg etriebruaisss d iorr."""
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
+ text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
+ na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
+ euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
+ one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
+ ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
+ gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
+ aBercaeu thllnrshicwsg etriebruaisss d iorr."""
- text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpnee</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# offset: 1
<s>apece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decryptMessage
|
Modified
|
Ciphey~Ciphey
|
e9ec74138c4b56f58ef519bce83320c944a57fd2
|
I think the message itself is broken
|
<0>:<add> logger.debug("Decrypting message in transposition the mesage is {message}")
<del> logger.debug("Decrypting message in transposition")
<32>:<add> logger.debug(f"The transposition decrypted message is {''.join(plaintext)}")
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decryptMessage(self, key, message):
<0> logger.debug("Decrypting message in transposition")
<1> # The transposition decrypt function will simulate the "columns" and
<2> # "rows" of the grid that the plaintext is written on by using a list
<3> # of strings. First, we need to calculate a few values.
<4>
<5> # The number of "columns" in our transposition grid:
<6> numOfColumns = math.ceil(len(message) / key)
<7> # The number of "rows" in our grid will need:
<8> numOfRows = key
<9> # The number of "shaded boxes" in the last "column" of the grid:
<10> numOfShadedBoxes = (numOfColumns * numOfRows) - len(message)
<11>
<12> # Each string in plaintext represents a column in the grid.
<13> plaintext = [""] * numOfColumns
<14>
<15> # The col and row variables point to where in the grid the next
<16> # character in the encrypted message will go.
<17> col = 0
<18> row = 0
<19>
<20> for symbol in message:
<21> plaintext[col] += symbol
<22> col += 1 # point to next column
<23>
<24> # If there are no more columns OR we're at a shaded box, go back to
<25> # the first column and the next row.
<26> if (col == numOfColumns) or (
<27> col == numOfColumns - 1 and row >= numOfRows - numOfShadedBoxes
<28> ):
<29> col = 0
<30> row += 1
<31>
<32> return "".join(plaintext)
<33>
|
===========unchanged ref 0===========
at: math
ceil(x: SupportsFloat, /) -> int
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
68141a8847f09100d09e8be41f00ad9eea8681f5
|
PEP8-ifying and more transposition fun
|
<1>:<del> text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
<2>:<del> na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
<3>:<del> euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
<4>:<del> one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
<5>:<del> ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
<6>:<del> gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
<7>:<del> aBercaeu thllnrshicwsg etriebruaisss d iorr."""
<8>:<add> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh me
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
<2> na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
<3> euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
<4> one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
<5> ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
<6> gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
<7> aBercaeu thllnrshicwsg etriebruaisss d iorr."""
<8> decryptedText = self.hackTransposition(text)
<9> return decryptedText
<10>
| |
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
68141a8847f09100d09e8be41f00ad9eea8681f5
|
PEP8-ifying and more transposition fun
|
<9>:<del> result = True
<21>:<del> return {
<22>:<add> return { "lc": self.lc,
<del> "lc": self.lc,
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> logger.debug("Entering transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> logger.debug(f"Transposition trying key {key}")
<4> decryptedText = self.decryptMessage(key, message)
<5> # if decrypted english is found, return them
<6> result = self.lc.checkLanguage(decryptedText)
<7> if key == 6:
<8> logger.debug(f"KEY 6 HAS BEEN REACHED")
<9> result = True
<10> if result:
<11> logger.debug("transposition returns true")
<12> return {
<13> "lc": self.lc,
<14> "IsPlaintext?": True,
<15> "Plaintext": decryptedText,
<16> "Cipher": "Transposition",
<17> "Extra Information": f"The key is {key}",
<18> }
<19>
<20> # it is not found
<21> return {
<22> "lc": self.lc,
<23> "IsPlaintext?": False,
<24> "Plaintext": None,
<25> "Cipher": "Transposition",
<26> "Extra Information": None,
<27> }
<28>
|
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
- na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
- euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
- one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
- ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
- gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
- aBercaeu thllnrshicwsg etriebruaisss d iorr."""
+ text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpnee</s>
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# offset: 1
<s>apece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
+
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.Decryptor.basicEncryption.basic_parent/BasicParent.__init__
|
Modified
|
Ciphey~Ciphey
|
68141a8847f09100d09e8be41f00ad9eea8681f5
|
PEP8-ifying and more transposition fun
|
<7>:<add> self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
<del> # self.list_of_objects = [self.caesar, self.reverse, self.pig]
<8>:<del> self.list_of_objects = [self.trans]
|
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.caesar = ca.Caesar(self.lc)
<2> self.reverse = re.Reverse(self.lc)
<3> self.viginere = vi.Viginere(self.lc)
<4> self.pig = pi.PigLatin(self.lc)
<5> self.trans = tr.Transposition(self.lc)
<6>
<7> # self.list_of_objects = [self.caesar, self.reverse, self.pig]
<8> self.list_of_objects = [self.trans]
<9>
|
===========unchanged ref 0===========
at: Decryptor.basicEncryption.caesar
Caesar(lc)
at: Decryptor.basicEncryption.pigLatin
PigLatin(lc)
at: ciphey.Decryptor.basicEncryption.basic_parent.BasicParent.decrypt
self.lc = self.lc + answer["lc"]
at: ciphey.Decryptor.basicEncryption.reverse
Reverse(lc)
at: ciphey.Decryptor.basicEncryption.transposition
Transposition(lc)
at: ciphey.Decryptor.basicEncryption.viginere
Viginere(lc)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
if key == 6:
logger.debug(f"KEY 6 HAS BEEN REACHED")
- result = True
if result:
logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
- return {
+ return { "lc": self.lc,
- "lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
- na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
- euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
- one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
- ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
- gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
- aBercaeu thllnrshicwsg etriebruaisss d iorr."""
+ text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpnee</s>
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# offset: 1
<s>apece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
+
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
68141a8847f09100d09e8be41f00ad9eea8681f5
|
PEP8-ifying and more transposition fun
|
<0>:<add> if not debug:
<add> logger.remove()
<4>:<del>
|
# module: ciphey.__main__
- # removes the logger
- # logger.remove()
+
class Ciphey:
+ def __init__(self, text, grep=False, cipher=False, debug=False):
- def __init__(self, text, grep=False, cipher=False):
<0> # general purpose modules
<1> self.ai = NeuralNetwork()
<2> self.lc = lc.LanguageChecker()
<3> self.mh = mh.mathsHelper()
<4>
<5> # the one bit of text given to us to decrypt
<6> self.text = text
<7> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<8>
<9> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<10>
<11> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<12>
<13> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<14>
<15> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<16>
<17> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<18>
<19> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<20>
<21> ffn Fc1o ge eohg dere.eec s nfap</s>
|
===========below chunk 0===========
# module: ciphey.__main__
- # removes the logger
- # logger.remove()
+
class Ciphey:
+ def __init__(self, text, grep=False, cipher=False, debug=False):
- def __init__(self, text, grep=False, cipher=False):
# offset: 1
BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========changed ref 0===========
# module: ciphey.__main__
-
- try:
- import mathsHelper as mh
- except ModuleNotFoundError:
- import ciphey.mathsHelper as mh
-
===========changed ref 1===========
# module: ciphey.__main__
warnings.filterwarnings("ignore")
-
-
- try:
- from languageCheckerMod import LanguageChecker as lc
- except ModuleNotFoundError:
- from ciphey.languageCheckerMod import LanguageChecker as lc
- try:
- from neuralNetworkMod.nn import NeuralNetwork
- except ModuleNotFoundError:
- from ciphey.neuralNetworkMod.nn import NeuralNetwork
-
- try:
- from Decryptor.basicEncryption.basic_parent import BasicParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.basicEncryption.basic_parent import BasicParent
-
- try:
- from Decryptor.Hash.hashParent import HashParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.Hash.hashParent import HashParent
- try:
- from Decryptor.Encoding.encodingParent import EncodingParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.Encoding.encodingParent import EncodingParent
===========changed ref 2===========
# module: ciphey.__main__
-
logger.add(
sys.stderr,
format="{time} {level} {message}",
filter="my_module",
level="DEBUG",
diagnose=True,
backtrace=True,
)
+ # removes the logger
+
+ # Depening on whether ciphey is called, or ciphey/__main__
+ # we need different imports to deal with both cases
+ try:
+ from languageCheckerMod import LanguageChecker as lc
+ from neuralNetworkMod.nn import NeuralNetwork
+ from Decryptor.basicEncryption.basic_parent import BasicParent
+ from Decryptor.Hash.hashParent import HashParent
+ from Decryptor.Encoding.encodingParent import EncodingParent
+ from Decryptor.Hash.hashParent import HashParent
+ except ModuleNotFoundError:
+ from ciphey.languageCheckerMod import LanguageChecker as lc
+ from ciphey.neuralNetworkMod.nn import NeuralNetwork
+ from ciphey.Decryptor.basicEncryption.basic_parent import BasicParent
+ from ciphey.Decryptor.Hash.hashParent import HashParent
+ from ciphey.Decryptor.Encoding.encodingParent import EncodingParent
+
+
+ try:
+ import mathsHelper as mh
+ except ModuleNotFoundError:
+ import ciphey.mathsHelper as mh
===========changed ref 3===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
self.trans = tr.Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
- # self.list_of_objects = [self.caesar, self.reverse, self.pig]
- self.list_of_objects = [self.trans]
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
if key == 6:
logger.debug(f"KEY 6 HAS BEEN REACHED")
- result = True
if result:
logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
- return {
+ return { "lc": self.lc,
- "lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 5===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """AaKoosoeDe5 b5sn ma reno ora'lhlrrceey e enlh
- na indeit n uhoretrm au ieu v er Ne2 gmanw,forwnlbsya apor tE.no
- euarisfatt e mealefedhsppmgAnlnoe(c -or)alat r lw o eb nglom,Ain
- one dtes ilhetcdba. t tg eturmudg,tfl1e1 v nitiaicynhrCsaemie-sp
- ncgHt nie cetrgmnoa yc r,ieaa toesa- e a0m82e1w shcnth ekh
- gaecnpeutaaieetgn iodhso d ro hAe snrsfcegrt NCsLc b17m8aEheideikfr
- aBercaeu thllnrshicwsg etriebruaisss d iorr."""
+ text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpnee</s>
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
68141a8847f09100d09e8be41f00ad9eea8681f5
|
PEP8-ifying and more transposition fun
|
<20>:<add> parser.add_argument(
<add> "-c",
<add> "--printcipher",
<add> help="Do you want information on the cipher used?",
<add> required=False,
<add> )
<add> parser.add_argument(
<add> "-d",
<add> "--debug",
<add> help="Activates debug mode"
<add> required=False,
<add> )
<29>:<add> if args['debug'] != None:
<add> debug = True
<32>:<add> cipherObj = Ciphey(args["text"], greppable, cipher, debug)
<del> cipherObj = Ciphey(args["text"], greppable, cipher)
|
# module: ciphey.__main__
def main():
<0> parser = argparse.ArgumentParser(
<1> description="Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it."
<2> )
<3> # parser.add_argument('-f','--file', help='File you want to decrypt', required=False)
<4> # parser.add_argument('-l','--level', help='How many levels of decryption you want (the more levels, the slower it is)', required=False)
<5> parser.add_argument(
<6> "-g",
<7> "--greppable",
<8> help="Only output the answer, no progress bars or information. Useful for grep",
<9> required=False,
<10> )
<11> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<12> # parser.add_argument('-s','--sicko-mode', help='If it is encrypted Ciphey WILL find it', required=False)
<13> parser.add_argument(
<14> "-c",
<15> "--printcipher",
<16> help="Do you want information on the cipher used?",
<17> required=False,
<18> )
<19>
<20> args = vars(parser.parse_args())
<21> if args["printcipher"] != None:
<22> cipher = True
<23> else:
<24> cipher = False
<25> if args["greppable"] != None:
<26> greppable = True
<27> else:
<28> greppable = False
<29>
<30> # uryyb zl sngure uryyb zl zbgure naq v ernyyl qb yvxr n tbbq ratyvfu oernxsnfg
<31> if args["text"]:
<32> cipherObj = Ciphey(args["text"], greppable, cipher)
<33> cipherObj.decrypt()
<34> else:
<35> print("No arguments were supplied. Look at the help menu with -h or --help</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def main():
# offset: 1
===========changed ref 0===========
# module: ciphey.__main__
-
- try:
- import mathsHelper as mh
- except ModuleNotFoundError:
- import ciphey.mathsHelper as mh
-
===========changed ref 1===========
# module: ciphey.__main__
warnings.filterwarnings("ignore")
-
-
- try:
- from languageCheckerMod import LanguageChecker as lc
- except ModuleNotFoundError:
- from ciphey.languageCheckerMod import LanguageChecker as lc
- try:
- from neuralNetworkMod.nn import NeuralNetwork
- except ModuleNotFoundError:
- from ciphey.neuralNetworkMod.nn import NeuralNetwork
-
- try:
- from Decryptor.basicEncryption.basic_parent import BasicParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.basicEncryption.basic_parent import BasicParent
-
- try:
- from Decryptor.Hash.hashParent import HashParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.Hash.hashParent import HashParent
- try:
- from Decryptor.Encoding.encodingParent import EncodingParent
- except ModuleNotFoundError:
- from ciphey.Decryptor.Encoding.encodingParent import EncodingParent
===========changed ref 2===========
# module: ciphey.__main__
-
logger.add(
sys.stderr,
format="{time} {level} {message}",
filter="my_module",
level="DEBUG",
diagnose=True,
backtrace=True,
)
+ # removes the logger
+
+ # Depening on whether ciphey is called, or ciphey/__main__
+ # we need different imports to deal with both cases
+ try:
+ from languageCheckerMod import LanguageChecker as lc
+ from neuralNetworkMod.nn import NeuralNetwork
+ from Decryptor.basicEncryption.basic_parent import BasicParent
+ from Decryptor.Hash.hashParent import HashParent
+ from Decryptor.Encoding.encodingParent import EncodingParent
+ from Decryptor.Hash.hashParent import HashParent
+ except ModuleNotFoundError:
+ from ciphey.languageCheckerMod import LanguageChecker as lc
+ from ciphey.neuralNetworkMod.nn import NeuralNetwork
+ from ciphey.Decryptor.basicEncryption.basic_parent import BasicParent
+ from ciphey.Decryptor.Hash.hashParent import HashParent
+ from ciphey.Decryptor.Encoding.encodingParent import EncodingParent
+
+
+ try:
+ import mathsHelper as mh
+ except ModuleNotFoundError:
+ import ciphey.mathsHelper as mh
===========changed ref 3===========
# module: ciphey.__main__
- # removes the logger
- # logger.remove()
+
class Ciphey:
+ def __init__(self, text, grep=False, cipher=False, debug=False):
- def __init__(self, text, grep=False, cipher=False):
+ if not debug:
+ logger.remove()
# general purpose modules
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.mh = mh.mathsHelper()
-
# the one bit of text given to us to decrypt
self.text = text
self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
ffn Fc1o ge eohg dere.eec s nfap yox hla y</s>
===========changed ref 4===========
# module: ciphey.__main__
- # removes the logger
- # logger.remove()
+
class Ciphey:
+ def __init__(self, text, grep=False, cipher=False, debug=False):
- def __init__(self, text, grep=False, cipher=False):
# offset: 1
<s>Mp a
ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========changed ref 5===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
def __init__(self, lc):
self.lc = lc
self.caesar = ca.Caesar(self.lc)
self.reverse = re.Reverse(self.lc)
self.viginere = vi.Viginere(self.lc)
self.pig = pi.PigLatin(self.lc)
self.trans = tr.Transposition(self.lc)
+ self.list_of_objects = [self.caesar, self.reverse, self.pig, self.trans]
- # self.list_of_objects = [self.caesar, self.reverse, self.pig]
- self.list_of_objects = [self.trans]
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
efea03e01b517768a5206779ff6be530b4a1a0ef
|
Bug Fixes
|
<8>:<del> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<9>:<del>
<10>:<del> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<11>:<del>
<12>:<del> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<13>:<del>
<14>:<del> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<15>:<del>
<16>:<del> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<17>:<del>
<18>:<del> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<19>:<del>
<20>:<del> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<21>:<del>
<22>:<del> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbd
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False, debug=False):
<0> if not debug:
<1> logger.remove()
<2> # general purpose modules
<3> self.ai = NeuralNetwork()
<4> self.lc = lc.LanguageChecker()
<5> self.mh = mh.mathsHelper()
<6> # the one bit of text given to us to decrypt
<7> self.text = text
<8> self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
<9>
<10> ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
<11>
<12> oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
<13>
<14> edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
<15>
<16> ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
<17>
<18> rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
<19>
<20> meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
<21>
<22> ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbd</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False, debug=False):
# offset: 1
BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
===========unchanged ref 0===========
at: Decryptor.Hash.hashParent
HashParent()
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: ciphey.neuralNetworkMod.nn
NeuralNetwork()
at: mathsHelper
mathsHelper()
at: neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
efea03e01b517768a5206779ff6be530b4a1a0ef
|
Bug Fixes
|
<21>:<del> "-c",
<22>:<del> "--printcipher",
<23>:<del> help="Do you want information on the cipher used?",
<24>:<del> required=False,
<25>:<del> )
<26>:<del> parser.add_argument(
<27>:<del> "-d",
<28>:<del> "--debug",
<29>:<del> help="Activates debug mode"
<30>:<del> required=False,
<31>:<add> "-d", "--debug", help="Activates debug mode", required=False,
<41>:<add> if args["debug"] != None:
<del> if args['debug'] != None:
|
# module: ciphey.__main__
def main():
<0> parser = argparse.ArgumentParser(
<1> description="Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it."
<2> )
<3> # parser.add_argument('-f','--file', help='File you want to decrypt', required=False)
<4> # parser.add_argument('-l','--level', help='How many levels of decryption you want (the more levels, the slower it is)', required=False)
<5> parser.add_argument(
<6> "-g",
<7> "--greppable",
<8> help="Only output the answer, no progress bars or information. Useful for grep",
<9> required=False,
<10> )
<11> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<12> # parser.add_argument('-s','--sicko-mode', help='If it is encrypted Ciphey WILL find it', required=False)
<13> parser.add_argument(
<14> "-c",
<15> "--printcipher",
<16> help="Do you want information on the cipher used?",
<17> required=False,
<18> )
<19>
<20> parser.add_argument(
<21> "-c",
<22> "--printcipher",
<23> help="Do you want information on the cipher used?",
<24> required=False,
<25> )
<26> parser.add_argument(
<27> "-d",
<28> "--debug",
<29> help="Activates debug mode"
<30> required=False,
<31> )
<32> args = vars(parser.parse_args())
<33> if args["printcipher"] != None:
<34> cipher = True
<35> else:
<36> cipher = False
<37> if args["greppable"] != None:
<38> greppable = True
<39> else:
<40> greppable = False
<41> if args['debug'] != None:
<42> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
def main():
# offset: 1
# uryyb zl sngure uryyb zl zbgure naq v ernyyl qb yvxr n tbbq ratyvfu oernxsnfg
if args["text"]:
cipherObj = Ciphey(args["text"], greppable, cipher, debug)
cipherObj.decrypt()
else:
print("No arguments were supplied. Look at the help menu with -h or --help")
===========unchanged ref 0===========
at: argparse.ArgumentParser
parse_args(args: Optional[Sequence[Text]], namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]]=...) -> Namespace
parse_args(*, namespace: None) -> Namespace
parse_args(args: Optional[Sequence[Text]], namespace: _N) -> _N
parse_args(*, namespace: _N) -> _N
at: argparse._ActionsContainer
add_argument(*name_or_flags: Text, action: Union[Text, Type[Action]]=..., nargs: Union[int, Text]=..., const: Any=..., default: Any=..., type: Union[Callable[[Text], _T], Callable[[str], _T], FileType]=..., choices: Iterable[_T]=..., required: bool=..., help: Optional[Text]=..., metavar: Optional[Union[Text, Tuple[Text, ...]]]=..., dest: Optional[Text]=..., version: Text=..., **kwargs: Any) -> Action
at: ciphey.__main__
Ciphey(text, grep=False, cipher=False, debug=False)
main()
at: ciphey.__main__.Ciphey
decrypt(self)
decrypt()
at: ciphey.__main__.main
parser = argparse.ArgumentParser(
description="Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it."
)
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False, debug=False):
if not debug:
logger.remove()
# general purpose modules
self.ai = NeuralNetwork()
self.lc = lc.LanguageChecker()
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text = text
- self.text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri
-
- ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaetee
-
- oinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fs
-
- edbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h a
-
- ihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.
-
- rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh
-
- meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a
-
- ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
-
- </s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False, debug=False):
# offset: 1
<s> hla yon. lnrnsreaBoa t,e eitsw il ulpbdofg
-
- BRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm
-
- -eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
logger.debug(f"The inputted text at __main__ is {self.text}")
# the decryptor components
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level = 1
self.sickomode = False
self.greppable = grep
self.cipher = cipher
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.decrypt
|
Modified
|
Ciphey~Ciphey
|
80efb85ff721c0b2d1dc6466e029f15cd84f5239
|
Transposition now works
|
<1>:<del> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<2>:<del>
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
<0> # Brute-force by looping through every possible key.
<1> text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
<2>
<3> decryptedText = self.hackTransposition(text)
<4> return decryptedText
<5>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition
hackTransposition(self, message)
hackTransposition(message)
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
80efb85ff721c0b2d1dc6466e029f15cd84f5239
|
Transposition now works
|
<7>:<del> if key == 6:
<8>:<del> logger.debug(f"KEY 6 HAS BEEN REACHED")
|
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
<0> logger.debug("Entering transposition")
<1> # brute-force by looping through every possible key
<2> for key in range(1, len(message)):
<3> logger.debug(f"Transposition trying key {key}")
<4> decryptedText = self.decryptMessage(key, message)
<5> # if decrypted english is found, return them
<6> result = self.lc.checkLanguage(decryptedText)
<7> if key == 6:
<8> logger.debug(f"KEY 6 HAS BEEN REACHED")
<9> if result:
<10> logger.debug("transposition returns true")
<11> return {
<12> "lc": self.lc,
<13> "IsPlaintext?": True,
<14> "Plaintext": decryptedText,
<15> "Cipher": "Transposition",
<16> "Extra Information": f"The key is {key}",
<17> }
<18>
<19> # it is not found
<20> return { "lc": self.lc,
<21> "IsPlaintext?": False,
<22> "Plaintext": None,
<23> "Cipher": "Transposition",
<24> "Extra Information": None,
<25> }
<26>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.transposition.Transposition.__init__
self.lc = lc
at: languageCheckerMod.LanguageChecker.LanguageChecker
checkLanguage(text)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.Decryptor.Hash.hashParent/HashParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
80efb85ff721c0b2d1dc6466e029f15cd84f5239
|
Transposition now works
|
<0>:<add> logger.debug(f"Calling hash crackers")
|
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
<0> result = hashBuster.crack(text)
<1> return result
<2>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Hash.hashBuster
crack(hashvalue)
===========changed ref 0===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
- if key == 6:
- logger.debug(f"KEY 6 HAS BEEN REACHED")
if result:
logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
return { "lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
80efb85ff721c0b2d1dc6466e029f15cd84f5239
|
Transposition now works
|
<0>:<add> logger.debug(f"Starting to crack hashes")
<5>:<add> logger.debug(f"md5 returns true")
<16>:<add> logger.debug(f"sha1 returns true")
<27>:<add> logger.debug(f"sha256 returns true")
<38>:<add> logger.debug(f"sha384 returns true")
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue):
<0> result = False
<1> if len(hashvalue) == 32:
<2> for api in md5:
<3> r = api(hashvalue, "md5")
<4> if r:
<5> return {
<6> "lc": None,
<7> "IsPlaintext?": True,
<8> "Plaintext": r,
<9> "Cipher": "md5",
<10> "Extra Information": None,
<11> }
<12> elif len(hashvalue) == 40:
<13> for api in sha1:
<14> r = api(hashvalue, "sha1")
<15> if r:
<16> return {
<17> "lc": None,
<18> "IsPlaintext?": True,
<19> "Plaintext": r,
<20> "Cipher": "sha1",
<21> "Extra Information": None,
<22> }
<23> elif len(hashvalue) == 64:
<24> for api in sha256:
<25> r = api(hashvalue, "sha256")
<26> if r:
<27> return {
<28> "lc": None,
<29> "IsPlaintext?": True,
<30> "Plaintext": r,
<31> "Cipher": "sha256",
<32> "Extra Information": None,
<33> }
<34> elif len(hashvalue) == 96:
<35> for api in sha384:
<36> r = api(hashvalue, "sha384")
<37> if r:
<38> return {
<39> "lc": None,
<40> "IsPlaintext?": True,
<41> "Plaintext": r,
<42> "Cipher": "sha384",
<43> "Extra Information": None,
<44> }
<45> elif len(hashvalue) == 128:
<46> for api in sha512:
<47> r = api(hashvalue, "sha512")
<48> if r:
</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue):
# offset: 1
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha512",
"Extra Information": None,
}
else:
return {
"lc": None,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": None,
"Extra Information": "The hash wasn't found. Please try Hashkiller.co.uk first, then use Hashcat to manually crack the hash.",
}
===========unchanged ref 0===========
at: ciphey.Decryptor.Hash.hashBuster
md5 = [gamma, alpha, beta, theta, delta]
sha1 = [alpha, beta, theta, delta]
sha256 = [alpha, beta, theta]
sha384 = [alpha, beta, theta]
sha512 = [alpha, beta, theta]
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
+ logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text)
return result
===========changed ref 1===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def hackTransposition(self, message):
logger.debug("Entering transposition")
# brute-force by looping through every possible key
for key in range(1, len(message)):
logger.debug(f"Transposition trying key {key}")
decryptedText = self.decryptMessage(key, message)
# if decrypted english is found, return them
result = self.lc.checkLanguage(decryptedText)
- if key == 6:
- logger.debug(f"KEY 6 HAS BEEN REACHED")
if result:
logger.debug("transposition returns true")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": decryptedText,
"Cipher": "Transposition",
"Extra Information": f"The key is {key}",
}
# it is not found
return { "lc": self.lc,
"IsPlaintext?": False,
"Plaintext": None,
"Cipher": "Transposition",
"Extra Information": None,
}
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.transposition
class Transposition:
def decrypt(self, text):
# Brute-force by looping through every possible key.
- text = """Cb b rssti aieih rooaopbrtnsceee er es no npfgcwu plri ch nitaalr eiuengiteehb(e1 hilincegeoamn fubehgtarndcstudmd nM eu eacBoltaeteeoinebcdkyremdteghn.aa2r81a condari fmps" tad l t oisn sit u1rnd stara nvhn fsedbh ee,n e necrg6 8nmisv l nc muiftegiitm tutmg cm shSs9fcie ebintcaets h aihda cctrhe ele 1O7 aaoem waoaatdahretnhechaopnooeapece9etfncdbgsoeb uuteitgna.rteoh add e,D7c1Etnpneehtn beete" evecoal lsfmcrl iu1cifgo ai. sl1rchdnheev sh meBd ies e9t)nh,htcnoecplrrh ,ide hmtlme. pheaLem,toeinfgn t e9yce da' eN eMp a ffn Fc1o ge eohg dere.eec s nfap yox hla yon. lnrnsreaBoa t,e eitsw il ulpbdofgBRe bwlmprraio po droB wtinue r Pieno nc ayieeto'lulcih sfnc ownaSserbereiaSm-eaiah, nnrttgcC maciiritvledastinideI nn rms iehn tsigaBmuoetcetias rn"""
-
decryptedText = self.hackTransposition(text)
return decryptedText
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
17bc389e4bdb4e017ca1f624dc2ef103fc0e270f
|
Pep8-ifying my code
|
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
<0> # Read the documentation for more on this function.
<1> self.probabilityDistribution = self.ai.predictnn(self.text)[0]
<2> self.whatToChoose = {
<3> self.hash: {
<4> "sha1": self.probabilityDistribution[0],
<5> "md5": self.probabilityDistribution[1],
<6> "sha256": self.probabilityDistribution[2],
<7> "sha512": self.probabilityDistribution[3],
<8> },
<9> self.basic: {"caesar": self.probabilityDistribution[4]},
<10> "plaintext": {"plaintext": self.probabilityDistribution[5]},
<11> self.encoding: {
<12> "reverse": self.probabilityDistribution[6],
<13> "base64": self.probabilityDistribution[7],
<14> "binary": self.probabilityDistribution[8],
<15> "hexadecimal": self.probabilityDistribution[9],
<16> "ascii": self.probabilityDistribution[10],
<17> "morse": self.probabilityDistribution[11],
<18> },
<19> }
<20>
<21> logger.debug(
<22> f"The probability table before 0.1 in __main__ is {self.whatToChoose}"
<23> )
<24> # sorts each indiviudal sub-dictionary
<25> for key, value in self.whatToChoose.items():
<26> for k, v in value.items():
<27> # Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
<28> if v < 0.01:
<29> self.whatToChoose[key][k] = 0.01
<30> logger.debug(
<31> f"The probability table after 0.1 in __main__ is {self.whatToChoose}"
<32> )
<33>
<34> for key, value in self.whatToChoose.items():
<35> self.whatToChoose[key] = self.mh.</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 1
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
logger.debug(
f"The new probability table after sorting in __main__ is {self.whatToChoose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt", "w")
self.one_level_of_decryption(file=f)
for i in range(0, self.</s>
===========below chunk 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 2
<s> self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.text = text
self.basic = BasicParent(self.lc)
self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
at: collections.OrderedDict
update = __update = _collections_abc.MutableMapping.update
update = __update = _collections_abc.MutableMapping.update
items() -> _OrderedDictItemsView[_KT, _VT]
__ne__ = _collections_abc.MutableMapping.__ne__
__marker = object()
at: neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
|
|
ciphey.__main__/Ciphey.one_level_of_decryption
|
Modified
|
Ciphey~Ciphey
|
17bc389e4bdb4e017ca1f624dc2ef103fc0e270f
|
Pep8-ifying my code
|
<0>:<add> # Calls one level of decryption
<add> # mainly used to control the progress bar
<del> items = range(1)
|
# module: ciphey.__main__
class Ciphey:
def one_level_of_decryption(self, file=None, sickomode=None):
<0> items = range(1)
<1> if self.greppable:
<2> logger.debug("__main__ is running as greppable")
<3> self.decryptNormal()
<4> else:
<5> with alive_bar() as bar:
<6> logger.debug("__main__ is running with progress bar")
<7> self.decryptNormal(bar)
<8>
|
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
decryptNormal(bar=None)
at: ciphey.__main__.Ciphey.__init__
self.greppable = grep
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# Read the documentation for more on this function.
self.probabilityDistribution = self.ai.predictnn(self.text)[0]
self.whatToChoose = {
self.hash: {
"sha1": self.probabilityDistribution[0],
"md5": self.probabilityDistribution[1],
"sha256": self.probabilityDistribution[2],
"sha512": self.probabilityDistribution[3],
},
self.basic: {"caesar": self.probabilityDistribution[4]},
"plaintext": {"plaintext": self.probabilityDistribution[5]},
self.encoding: {
"reverse": self.probabilityDistribution[6],
"base64": self.probabilityDistribution[7],
"binary": self.probabilityDistribution[8],
"hexadecimal": self.probabilityDistribution[9],
"ascii": self.probabilityDistribution[10],
"morse": self.probabilityDistribution[11],
},
}
logger.debug(
f"The probability table before 0.1 in __main__ is {self.whatToChoose}"
)
# sorts each indiviudal sub-dictionary
for key, value in self.whatToChoose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
self.whatToChoose[key][k] = 0.01
logger.debug(
f"The probability table after 0.1 in __main__ is {self.whatToChoose}"
)
for key, value in self.whatToChoose.items():
self.whatToChoose[key] = self.mh.sortDictionary(value)
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
</s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 1
<s>
self.whatToChoose = self.mh.sortProbTable(self.whatToChoose)
# the below code selects the most likely one
# and places it at the front
new_dict = {}
maximum = 0.00
max_key = None
max_val = None
for key, value in self.whatToChoose.items():
val = next(iter(value))
val = value[val]
if val >= maximum:
maximum = val
max_key = key
max_val = value
new_dict = collections.OrderedDict()
new_dict[max_key] = max_val
- temp = self.whatToChoose
for key, value in self.whatToChoose.items():
if key == max_key:
continue
new_dict[key] = value
# ok so this looks wacky but hear me out here
# a.update(b)
# adds all content of dict b onto end of dict a
# no way to add it to front, so I have to do this :)
self.whatToChoose = new_dict
logger.debug(
f"The new probability table after sorting in __main__ is {self.whatToChoose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
if self.level <= 1:
self.one_level_of_decryption()
else:
if self.sickomode:
print("Sicko mode entered")
f = open("decryptionContents.txt",</s>
===========changed ref 2===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self):
# offset: 2
<s>")
self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
e718524651861d9835ca27798b1d79aa29802422
|
Switching to Rich
|
<17>:<add> self.console = Console()
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, text, grep=False, cipher=False, debug=False):
<0> if not debug:
<1> logger.remove()
<2> # general purpose modules
<3> self.ai = NeuralNetwork()
<4> self.lc = lc.LanguageChecker()
<5> self.mh = mh.mathsHelper()
<6> # the one bit of text given to us to decrypt
<7> self.text = text
<8> logger.debug(f"The inputted text at __main__ is {self.text}")
<9> # the decryptor components
<10> self.basic = BasicParent(self.lc)
<11> self.hash = HashParent()
<12> self.encoding = EncodingParent(self.lc)
<13> self.level = 1
<14> self.sickomode = False
<15> self.greppable = grep
<16> self.cipher = cipher
<17>
|
===========unchanged ref 0===========
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: ciphey.Decryptor.Hash.hashParent
HashParent()
at: ciphey.languageCheckerMod.LanguageChecker
LanguageChecker()
at: ciphey.neuralNetworkMod.nn
NeuralNetwork()
at: mathsHelper
mathsHelper()
|
ciphey.Decryptor.Hash.hashBuster/beta
|
Modified
|
Ciphey~Ciphey
|
5c3a81c53c03bd60395e00f26c0bef5413865ec0
|
Implementing timeouts in hash busdter
|
<1>:<add> "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
<del> "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue
|
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
<0> response = requests.get(
<1> "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue
<2> ).text
<3> match = re.search(r'/generate-hash/?text=.*?"', response)
<4> if match:
<5> return match.group(1)
<6> else:
<7> return False
<8>
|
===========unchanged ref 0===========
at: requests.api
get(url: Union[Text, bytes], params: Optional[
Union[
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType],
Tuple[_ParamsMappingKeyType, _ParamsMappingValueType],
Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
Union[Text, bytes],
]
]=..., **kwargs) -> Response
|
ciphey.Decryptor.Hash.hashBuster/gamma
|
Modified
|
Ciphey~Ciphey
|
5c3a81c53c03bd60395e00f26c0bef5413865ec0
|
Implementing timeouts in hash busdter
|
<0>:<add> response = requests.get(
<add> "https://www.nitrxgen.net/md5db/" + hashvalue, timeout=5
<del> response = requests.get("https://www.nitrxgen.net/md5db/" + hashvalue).text
<1>:<add> ).text
|
# module: ciphey.Decryptor.Hash.hashBuster
def gamma(hashvalue, hashtype):
<0> response = requests.get("https://www.nitrxgen.net/md5db/" + hashvalue).text
<1> if response:
<2> return response
<3> else:
<4> return False
<5>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Hash.hashBuster.beta
response = requests.get(
"https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
).text
at: re
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
at: requests.models.Response
__attrs__ = [
"_content",
"status_code",
"headers",
"url",
"history",
"encoding",
"reason",
"cookies",
"elapsed",
"request",
]
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
response = requests.get(
+ "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
- "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue
).text
match = re.search(r'/generate-hash/?text=.*?"', response)
if match:
return match.group(1)
else:
return False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.