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
|
---|---|---|---|---|---|---|---|
tests.enciphey/encipher_crypto.Base64
|
Modified
|
Ciphey~Ciphey
|
53f04e38838452f50f66b5c95dca61fef6a496a2
|
Quickly fixed tests
|
<7>:<add> return base64.b64encode(bytes(text, "utf-8")).decode("utf-8")
<del> return base64.b64encode(bytes(text, "utf-8"))
|
# module: tests.enciphey
class encipher_crypto:
def Base64(self, text: str) -> str:
<0> """Turns text in base64 using Python libray
<1>
<2> args:
<3> text -> text convert
<4>
<5> returns:
<6> text -> as base 64"""
<7> return base64.b64encode(bytes(text, "utf-8"))
<8>
|
===========unchanged ref 0===========
at: base64
b64encode(s: _encodable, altchars: Optional[bytes]=...) -> bytes
|
tests.enciphey/encipher_crypto.Base32
|
Modified
|
Ciphey~Ciphey
|
53f04e38838452f50f66b5c95dca61fef6a496a2
|
Quickly fixed tests
|
<7>:<add> return base64.b32encode(bytes(text, "utf-8")).decode("utf-8")
<del> return base64.b32encode(bytes(text, "utf-8"))
|
# module: tests.enciphey
class encipher_crypto:
def Base32(self, text: str) -> str:
<0> """Turns text in base64 using Python libray
<1>
<2> args:
<3> text -> text convert
<4>
<5> returns:
<6> text -> as base 64"""
<7> return base64.b32encode(bytes(text, "utf-8"))
<8>
|
===========unchanged ref 0===========
at: base64
b32encode(s: _encodable) -> bytes
===========changed ref 0===========
# module: tests.enciphey
class encipher_crypto:
def Base64(self, text: str) -> str:
"""Turns text in base64 using Python libray
args:
text -> text convert
returns:
text -> as base 64"""
+ return base64.b64encode(bytes(text, "utf-8")).decode("utf-8")
- return base64.b64encode(bytes(text, "utf-8"))
|
tests.enciphey/encipher_crypto.Base16
|
Modified
|
Ciphey~Ciphey
|
53f04e38838452f50f66b5c95dca61fef6a496a2
|
Quickly fixed tests
|
<7>:<add> return base64.b16encode(bytes(text, "utf-8")).decode("utf-8")
<del> return base64.b16encode(bytes(text, "utf-8"))
|
# module: tests.enciphey
class encipher_crypto:
def Base16(self, text: str) -> str:
<0> """Turns text in base64 using Python libray
<1>
<2> args:
<3> text -> text convert
<4>
<5> returns:
<6> text -> as base 64"""
<7> return base64.b16encode(bytes(text, "utf-8"))
<8>
|
===========unchanged ref 0===========
at: base64
b16encode(s: _encodable) -> bytes
===========changed ref 0===========
# module: tests.enciphey
class encipher_crypto:
def Base32(self, text: str) -> str:
"""Turns text in base64 using Python libray
args:
text -> text convert
returns:
text -> as base 64"""
+ return base64.b32encode(bytes(text, "utf-8")).decode("utf-8")
- return base64.b32encode(bytes(text, "utf-8"))
===========changed ref 1===========
# module: tests.enciphey
class encipher_crypto:
def Base64(self, text: str) -> str:
"""Turns text in base64 using Python libray
args:
text -> text convert
returns:
text -> as base 64"""
+ return base64.b64encode(bytes(text, "utf-8")).decode("utf-8")
- return base64.b64encode(bytes(text, "utf-8"))
|
tests.generate_tests/test_generator.__init__
|
Modified
|
Ciphey~Ciphey
|
b298302f9d74cbfe460343b5fd74a9042e18a15a
|
Upload all tests
|
<0>:<add> self.HOW_MANY_TESTS = 100
<del> self.HOW_MANY_TESTS = 2
|
# module: tests.generate_tests
class test_generator:
def __init__(self):
<0> self.HOW_MANY_TESTS = 2
<1> self.enCiphey_obj = enciphey.encipher()
<2>
|
===========unchanged ref 0===========
at: enciphey
encipher()
|
ciphey.Decryptor.Encoding.bases/Bases.base85
|
Modified
|
Ciphey~Ciphey
|
05ebf5a95f83ce763d88aaebedba9c4b2d8db5d3
|
Uplaoded tests
|
<8>:<del> result = None
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def base85(self, text: str):
<0> """Base85 decode
<1>
<2> args:
<3> text -> text to decode
<4> returns:
<5> the text decoded as base85
<6> """
<7> logger.trace("Attempting base85")
<8> result = None
<9> return self._dispatch(base64.b85decode, text, "base85")
<10>
|
===========unchanged ref 0===========
at: base64
b85decode(b: _decodable) -> bytes
at: ciphey.Decryptor.Encoding.bases.Bases
_dispatch(decoder: Callable[[str], bytes], text: str, cipher: str)
|
ciphey.Decryptor.Hash.hashParent/HashParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
9b6493416eb873e95e763257f85fc660c1ae0b9e
|
Fixing bug
|
<1>:<add> result = hashBuster.crack(text, self.lc)
<del> result = hashBuster.crack(text)
|
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+
def decrypt(self, text):
<0> logger.debug(f"Calling hash crackers")
<1> result = hashBuster.crack(text)
<2> return result
<3>
|
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+ def __init__(self, lc):
+ self.lc = lc
+
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
9b6493416eb873e95e763257f85fc660c1ae0b9e
|
Fixing bug
|
<12>:<add> self.hash = HashParent(self.lc)
<del> self.hash = HashParent()
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
<0> logger.remove()
<1> logger.configure()
<2> logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
<3> logger.opt(colors=True)
<4> logger.debug(f"""Debug level set to {config["debug"]}""")
<5> # general purpose modules
<6> self.ai = NeuralNetwork()
<7> self.lc = config["checker"](config)
<8> self.mh = mh.mathsHelper()
<9> # the one bit of text given to us to decrypt
<10> self.text: str = config["ctext"]
<11> self.basic = BasicParent(self.lc)
<12> self.hash = HashParent()
<13> self.encoding = EncodingParent(self.lc)
<14> self.level: int = 1
<15> self.greppable: bool = config["grep"]
<16> self.cipher_info = config["info"]
<17> self.console = Console()
<18> self.probability_distribution: dict = {}
<19> self.what_to_choose: dict = {}
<20>
|
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: Decryptor.Hash.hashParent
HashParent(lc)
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.__main__.Ciphey.decrypt
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
at: ciphey.mathsHelper
mathsHelper()
at: neuralNetworkMod.nn
NeuralNetwork()
at: sys
stderr: TextIO
at: typing.IO
__slots__ = ()
isatty() -> bool
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
+ result = hashBuster.crack(text, self.lc)
- result = hashBuster.crack(text)
return result
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
9b6493416eb873e95e763257f85fc660c1ae0b9e
|
Fixing bug
|
<5>:<add> result = lc.checkLanguage(r)
<add> if result:
<del> if r:
<6>:<add> logger.debug(f"MD5 returns True {r}")
<del> logger.debug(f"md5 returns true")
<29>:<add> result = lc.checkLanguage(r)
<add> if result:
<del> if r:
<41>:<add> result = lc.checkLanguage(r)
<add> if result:
<del> if r:
|
# module: ciphey.Decryptor.Hash.hashBuster
+ def crack(hashvalue, lc):
- def crack(hashvalue):
<0> logger.debug(f"Starting to crack hashes")
<1> result = False
<2> if len(hashvalue) == 32:
<3> for api in md5:
<4> r = api(hashvalue, "md5")
<5> if r:
<6> logger.debug(f"md5 returns true")
<7> return {
<8> "lc": None,
<9> "IsPlaintext?": True,
<10> "Plaintext": r,
<11> "Cipher": "md5",
<12> "Extra Information": None,
<13> }
<14> elif len(hashvalue) == 40:
<15> for api in sha1:
<16> r = api(hashvalue, "sha1")
<17> if r:
<18> logger.debug(f"sha1 returns true")
<19> return {
<20> "lc": None,
<21> "IsPlaintext?": True,
<22> "Plaintext": r,
<23> "Cipher": "sha1",
<24> "Extra Information": None,
<25> }
<26> elif len(hashvalue) == 64:
<27> for api in sha256:
<28> r = api(hashvalue, "sha256")
<29> if r:
<30> logger.debug(f"sha256 returns true")
<31> return {
<32> "lc": None,
<33> "IsPlaintext?": True,
<34> "Plaintext": r,
<35> "Cipher": "sha256",
<36> "Extra Information": None,
<37> }
<38> elif len(hashvalue) == 96:
<39> for api in sha384:
<40> r = api(hashvalue, "sha384")
<41> if r:
<42> logger.debug(f"sha384 returns true")
<43> return {
<44> "lc": None,
<45> "Is</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
+ def crack(hashvalue, lc):
- def crack(hashvalue):
# offset: 1
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
if r:
logger.debug(f"sha512 returns true")
return {
"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 __init__(self, lc):
+ self.lc = lc
+
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
+ result = hashBuster.crack(text, self.lc)
- result = hashBuster.crack(text)
return result
===========changed ref 2===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
logger.remove()
logger.configure()
logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
logger.opt(colors=True)
logger.debug(f"""Debug level set to {config["debug"]}""")
# general purpose modules
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
+ self.hash = HashParent(self.lc)
- self.hash = HashParent()
self.encoding = EncodingParent(self.lc)
self.level: int = 1
self.greppable: bool = config["grep"]
self.cipher_info = config["info"]
self.console = Console()
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
|
ciphey.Decryptor.Hash.hashParent/HashParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<2>:<add> logger.debug(f"Returning {result}")
|
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
<0> logger.debug(f"Calling hash crackers")
<1> result = hashBuster.crack(text, self.lc)
<2> return result
<3>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Hash.hashBuster
crack(hashvalue, lc)
at: ciphey.Decryptor.Hash.hashParent.HashParent.__init__
self.lc = lc
|
ciphey.Decryptor.Hash.hashBuster/alpha
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<0>:<add> return None
<del> return False
|
# module: ciphey.Decryptor.Hash.hashBuster
def alpha(hashvalue, hashtype):
<0> return False
<1>
|
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/beta
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<10>:<add> return None
<del> return False
|
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
<0> try:
<1> response = requests.get(
<2> "https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
<3> ).text
<4> except requests.exceptions.ReadTimeout as e:
<5> logger.debug(f"Beta failed timeout {e}")
<6> match = re.search(r'/generate-hash/?text=.*?"', response)
<7> if match:
<8> return match.group(1)
<9> else:
<10> return False
<11>
|
===========unchanged ref 0===========
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.api
get(url: Union[Text, bytes], params: Optional[
Union[
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType],
Tuple[_ParamsMappingKeyType, _ParamsMappingValueType],
Iterable[Tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
Union[Text, bytes],
]
]=..., **kwargs) -> Response
at: requests.exceptions
ReadTimeout(*args, **kwargs)
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 alpha(hashvalue, hashtype):
+ return None
- return False
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/gamma
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<9>:<add> return None
<del> return False
|
# module: ciphey.Decryptor.Hash.hashBuster
def gamma(hashvalue, hashtype):
<0> try:
<1> response = requests.get(
<2> "https://www.nitrxgen.net/md5db/" + hashvalue, timeout=5
<3> ).text
<4> except requests.exceptions.ReadTimeout as e:
<5> logger.debug(f"Gamma failed with {e}")
<6> if response:
<7> return response
<8> else:
<9> return False
<10>
|
===========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
at: requests.exceptions
ReadTimeout(*args, **kwargs)
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def alpha(hashvalue, hashtype):
+ return None
- return False
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
try:
response = requests.get(
"https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Beta failed timeout {e}")
match = re.search(r'/generate-hash/?text=.*?"', response)
if match:
return match.group(1)
else:
+ return None
- return False
===========changed ref 2===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/delta
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<6>:<add> return None
<del> return False
|
# module: ciphey.Decryptor.Hash.hashBuster
def delta(hashvalue, hashtype):
<0> # data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'}
<1> # response = requests.post('http://hashcrack.com/index.php' , data).text
<2> # match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response)
<3> # if match:
<4> # return match.group(1)
<5> # else:
<6> return False
<7>
|
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def alpha(hashvalue, hashtype):
+ return None
- return False
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashBuster
def gamma(hashvalue, hashtype):
try:
response = requests.get(
"https://www.nitrxgen.net/md5db/" + hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Gamma failed with {e}")
if response:
return response
else:
+ return None
- return False
===========changed ref 2===========
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
try:
response = requests.get(
"https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Beta failed timeout {e}")
match = re.search(r'/generate-hash/?text=.*?"', response)
if match:
return match.group(1)
else:
+ return None
- return False
===========changed ref 3===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/theta
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<11>:<add> return None
<del> return False
|
# module: ciphey.Decryptor.Hash.hashBuster
def theta(hashvalue, hashtype):
<0> try:
<1> response = requests.get(
<2> "https://md5decrypt.net/Api/api.php?hash=%s&hash_type=%s&[email protected]&code=1152464b80a61728"
<3> % (hashvalue, hashtype),
<4> timeout=5,
<5> ).text
<6> except requests.exceptions.ReadTimeout as e:
<7> logger.debug(f"Gamma failed with {e}")
<8> if len(response) != 0:
<9> return response
<10> else:
<11> return False
<12>
|
===========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
at: requests.exceptions
ReadTimeout(*args, **kwargs)
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def alpha(hashvalue, hashtype):
+ return None
- return False
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashBuster
def gamma(hashvalue, hashtype):
try:
response = requests.get(
"https://www.nitrxgen.net/md5db/" + hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Gamma failed with {e}")
if response:
return response
else:
+ return None
- return False
===========changed ref 2===========
# module: ciphey.Decryptor.Hash.hashBuster
def delta(hashvalue, hashtype):
# data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'}
# response = requests.post('http://hashcrack.com/index.php' , data).text
# match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response)
# if match:
# return match.group(1)
# else:
+ return None
- return False
===========changed ref 3===========
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
try:
response = requests.get(
"https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Beta failed timeout {e}")
match = re.search(r'/generate-hash/?text=.*?"', response)
if match:
return match.group(1)
else:
+ return None
- return False
===========changed ref 4===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
17d6d9848635f885f5a3ba5c18607cbe732aca2e
|
Why u return none
|
<5>:<add> result = lc.checkLanguage(r) if r is not None else None
<del> result = lc.checkLanguage(r)
<6>:<add> if result and r is not None:
<del> if result:
<18>:<add> result = lc.checkLanguage(r) if r is not None else None
<add> if result and r is not None:
<del> if r:
<30>:<add> result = lc.checkLanguage(r) if r is not None else None
<del> result = lc.checkLanguage(r)
<31>:<add> if result and r is not None:
<del> if result:
<43>:<add> result = lc.checkLanguage(r) if r is not None else None
<del> result = lc.checkLanguage(r)
<44>:<add> if result and r is not None:
<del> if result:
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
<0> logger.debug(f"Starting to crack hashes")
<1> result = False
<2> if len(hashvalue) == 32:
<3> for api in md5:
<4> r = api(hashvalue, "md5")
<5> result = lc.checkLanguage(r)
<6> if result:
<7> logger.debug(f"MD5 returns True {r}")
<8> return {
<9> "lc": None,
<10> "IsPlaintext?": True,
<11> "Plaintext": r,
<12> "Cipher": "md5",
<13> "Extra Information": None,
<14> }
<15> elif len(hashvalue) == 40:
<16> for api in sha1:
<17> r = api(hashvalue, "sha1")
<18> if r:
<19> logger.debug(f"sha1 returns true")
<20> return {
<21> "lc": None,
<22> "IsPlaintext?": True,
<23> "Plaintext": r,
<24> "Cipher": "sha1",
<25> "Extra Information": None,
<26> }
<27> elif len(hashvalue) == 64:
<28> for api in sha256:
<29> r = api(hashvalue, "sha256")
<30> result = lc.checkLanguage(r)
<31> if result:
<32> logger.debug(f"sha256 returns true")
<33> return {
<34> "lc": None,
<35> "IsPlaintext?": True,
<36> "Plaintext": r,
<37> "Cipher": "sha256",
<38> "Extra Information": None,
<39> }
<40> elif len(hashvalue) == 96:
<41> for api in sha384:
<42> r = api(hashvalue, "sha384")
<43> result = lc.checkLanguage(r)
<44> if result:
<45> </s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
# offset: 1
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
result = lc.checkLanguage(r)
if result:
logger.debug(f"sha512 returns true")
return {
"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.hashBuster
def alpha(hashvalue, hashtype):
+ return None
- return False
===========changed ref 1===========
# module: ciphey.Decryptor.Hash.hashBuster
def gamma(hashvalue, hashtype):
try:
response = requests.get(
"https://www.nitrxgen.net/md5db/" + hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Gamma failed with {e}")
if response:
return response
else:
+ return None
- return False
===========changed ref 2===========
# module: ciphey.Decryptor.Hash.hashBuster
def delta(hashvalue, hashtype):
# data = {'auth':'8272hgt', 'hash':hashvalue, 'string':'','Submit':'Submit'}
# response = requests.post('http://hashcrack.com/index.php' , data).text
# match = re.search(r'<span class=hervorheb2>(.*?)</span></div></TD>', response)
# if match:
# return match.group(1)
# else:
+ return None
- return False
===========changed ref 3===========
# module: ciphey.Decryptor.Hash.hashBuster
def theta(hashvalue, hashtype):
try:
response = requests.get(
"https://md5decrypt.net/Api/api.php?hash=%s&hash_type=%s&[email protected]&code=1152464b80a61728"
% (hashvalue, hashtype),
timeout=5,
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Gamma failed with {e}")
if len(response) != 0:
return response
else:
+ return None
- return False
===========changed ref 4===========
# module: ciphey.Decryptor.Hash.hashBuster
def beta(hashvalue, hashtype):
try:
response = requests.get(
"https://hashtoolkit.com/reverse-hash/?hash=", hashvalue, timeout=5
).text
except requests.exceptions.ReadTimeout as e:
logger.debug(f"Beta failed timeout {e}")
match = re.search(r'/generate-hash/?text=.*?"', response)
if match:
return match.group(1)
else:
+ return None
- return False
===========changed ref 5===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
def decrypt(self, text):
logger.debug(f"Calling hash crackers")
result = hashBuster.crack(text, self.lc)
+ logger.debug(f"Returning {result}")
return result
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
871b0ca9c454b6d3d457a137e95192adf789bfe3
|
All tests now pass
|
<6>:<add> if result is not None or r is not None:
<del> if result and r is not None:
<19>:<add> if result is not None and r is not None:
<del> if result and r is not None:
<32>:<add> if result is not None and r is not None:
<del> if result and r is not None:
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
<0> logger.debug(f"Starting to crack hashes")
<1> result = False
<2> if len(hashvalue) == 32:
<3> for api in md5:
<4> r = api(hashvalue, "md5")
<5> result = lc.checkLanguage(r) if r is not None else None
<6> if result and r is not None:
<7> logger.debug(f"MD5 returns True {r}")
<8> return {
<9> "lc": None,
<10> "IsPlaintext?": True,
<11> "Plaintext": r,
<12> "Cipher": "md5",
<13> "Extra Information": None,
<14> }
<15> elif len(hashvalue) == 40:
<16> for api in sha1:
<17> r = api(hashvalue, "sha1")
<18> result = lc.checkLanguage(r) if r is not None else None
<19> if result and r is not None:
<20> logger.debug(f"sha1 returns true")
<21> return {
<22> "lc": None,
<23> "IsPlaintext?": True,
<24> "Plaintext": r,
<25> "Cipher": "sha1",
<26> "Extra Information": None,
<27> }
<28> elif len(hashvalue) == 64:
<29> for api in sha256:
<30> r = api(hashvalue, "sha256")
<31> result = lc.checkLanguage(r) if r is not None else None
<32> if result and r is not None:
<33> logger.debug(f"sha256 returns true")
<34> return {
<35> "lc": None,
<36> "IsPlaintext?": True,
<37> "Plaintext": r,
<38> "Cipher": "sha256",
<39> "Extra Information": None,
<40> }
<41> elif len(hashvalue) == 96:</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
# offset: 1
for api in sha384:
r = api(hashvalue, "sha384")
result = lc.checkLanguage(r) if r is not None else None
if result and r is not None:
logger.debug(f"sha384 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
result = lc.checkLanguage(r) if r is not None else None
if result and r is not None:
logger.debug(f"sha512 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha512",
"Extra Information": None,
}
else:
logger.debug(f"Returnign None packet")
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]
|
tests.generate_tests/test_generator.__init__
|
Modified
|
Ciphey~Ciphey
|
d9c0188fb4c5a30559efb74f65e7fdb38b60ef75
|
Changed tests
|
<0>:<add> self.HOW_MANY_TESTS = 10
<del> self.HOW_MANY_TESTS = 100
|
# module: tests.generate_tests
class test_generator:
def __init__(self):
<0> self.HOW_MANY_TESTS = 100
<1> self.enCiphey_obj = enciphey.encipher()
<2>
|
===========unchanged ref 0===========
at: enciphey
encipher()
|
tests.enciphey/encipher.__init__
|
Modified
|
Ciphey~Ciphey
|
d9c0188fb4c5a30559efb74f65e7fdb38b60ef75
|
Changed tests
|
<1>:<add> self.text = self.read_text()
<del> self.text = self.read_text()[0:200]
<2>:<add> self.MAX_SENTENCE_LENGTH = 20
<del> self.MAX_SENTENCE_LENGTH = 1
|
# module: tests.enciphey
class encipher:
def __init__(self):
<0> """Inits the encipher object """
<1> self.text = self.read_text()[0:200]
<2> self.MAX_SENTENCE_LENGTH = 1
<3> # ntlk.download("punkt")
<4> self.crypto = encipher_crypto()
<5>
|
===========unchanged ref 0===========
at: tests.enciphey
encipher_crypto()
at: tests.enciphey.encipher
read_text()
===========changed ref 0===========
# module: tests.generate_tests
class test_generator:
def __init__(self):
+ self.HOW_MANY_TESTS = 10
- self.HOW_MANY_TESTS = 100
self.enCiphey_obj = enciphey.encipher()
===========changed ref 1===========
# module: tests.test_main_generated
- def test_Vigenere_mLZpzFRz():
- # {'PlainText Sentences': 'Some hon.', 'Encrypted Texts': {'PlainText': 'Some hon.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 2===========
# module: tests.test_main_generated
- def test_Base32_slQVszGs():
- # {'PlainText Sentences': 'Hon.', 'Encrypted Texts': {'PlainText': 'Hon.', 'EncryptedText': 'JBXW4LQ=', 'CipherUsed': 'Base32'}}
- cfg = make_default_config('''JBXW4LQ=''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 3===========
# module: tests.test_main_generated
- def test_Vigenere_fsMzUIin():
- # {'PlainText Sentences': 'The names just announced are on the second ballot.', 'Encrypted Texts': {'PlainText': 'The names just announced are on the second ballot.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 4===========
# module: tests.test_main_generated
- def test_Vigenere_EknWSccJ():
- # {'PlainText Sentences': 'I am, as you know, a servant of this House.', 'Encrypted Texts': {'PlainText': 'I am, as you know, a servant of this House.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 5===========
# module: tests.test_main_generated
- def test_Hex_mhvLTVuR():
- # {'PlainText Sentences': 'Some hon.', 'Encrypted Texts': {'PlainText': 'Some hon.', 'EncryptedText': '536f6d6520686f6e2e', 'CipherUsed': 'Hex'}}
- cfg = make_default_config('''536f6d6520686f6e2e''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 6===========
# module: tests.test_main_generated
- def test_Vigenere_jrNqQHMc():
- # {'PlainText Sentences': "Canadians feel better about their own future and the country's future.", 'Encrypted Texts': {'PlainText': "Canadians feel better about their own future and the country's future.", 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 7===========
# module: tests.test_main_generated
- def test_Vigenere_hxAjhyrq():
- # {'PlainText Sentences': 'I would also ask that you seek the consent of the House to make your election unanimous.', 'Encrypted Texts': {'PlainText': 'I would also ask that you seek the consent of the House to make your election unanimous.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 8===========
# module: tests.test_main_generated
- def test_Vigenere_yllFrTMd():
- # {'PlainText Sentences': 'Canada represents a triumph of the human spirit, bringing together the best of what people can do.', 'Encrypted Texts': {'PlainText': 'Canada represents a triumph of the human spirit, bringing together the best of what people can do.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 9===========
# module: tests.test_main_generated
- def test_Vigenere_ktHWRXDs():
- # {'PlainText Sentences': 'You have come here because you have been chosen to be the spokespersons for Canadians across the land.', 'Encrypted Texts': {'PlainText': 'You have come here because you have been chosen to be the spokespersons for Canadians across the land.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 10===========
# module: tests.test_main_generated
- def test_Vigenere_GVbExvIY():
- # {'PlainText Sentences': 'My dear colleagues, thank you again for the honour that you have bestowed on me today.', 'Encrypted Texts': {'PlainText': 'My dear colleagues, thank you again for the honour that you have bestowed on me today.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 11===========
# module: tests.test_main_generated
- def test_Vigenere_PdRAqPIj():
- # {'PlainText Sentences': 'My dear colleagues, thank you again for the honour that you have bestowed on me today.', 'Encrypted Texts': {'PlainText': 'My dear colleagues, thank you again for the honour that you have bestowed on me today.', 'EncryptedText': None, 'CipherUsed': 'Vigenere'}}
- cfg = make_default_config('''None''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
===========changed ref 12===========
# module: tests.test_main_generated
- def test_Reverse_CRXXELEM():
- # {'PlainText Sentences': 'We are an open and democratic society.', 'Encrypted Texts': {'PlainText': 'We are an open and democratic society.', 'EncryptedText': '.yteicos citarcomed dna nepo na era eW', 'CipherUsed': 'Reverse'}}
- cfg = make_default_config('''.yteicos citarcomed dna nepo na era eW''')
- cfg["debug"] = "TRACE"
- result = main(cfg)
-
- assert result["IsPlaintext?"] == True
-
|
tests.generate_tests/test_generator.__init__
|
Modified
|
Ciphey~Ciphey
|
96ad25cf5947642340a25e8f7f5ceec5dfb8c20d
|
HUEL
|
<0>:<add> self.HOW_MANY_TESTS = 5
<del> self.HOW_MANY_TESTS = 10
|
# module: tests.generate_tests
class test_generator:
def __init__(self):
<0> self.HOW_MANY_TESTS = 10
<1> self.enCiphey_obj = enciphey.encipher()
<2>
|
===========unchanged ref 0===========
at: enciphey
encipher()
|
tests.generate_tests/test_generator.__init__
|
Modified
|
Ciphey~Ciphey
|
f1f0b20e809e965fc67479108c2ed067d9e17d13
|
Testing codecov yml
|
<0>:<add> self.HOW_MANY_TESTS = 2
<del> self.HOW_MANY_TESTS = 5
|
# module: tests.generate_tests
class test_generator:
def __init__(self):
<0> self.HOW_MANY_TESTS = 5
<1> self.enCiphey_obj = enciphey.encipher()
<2>
|
===========unchanged ref 0===========
at: enciphey
encipher()
|
ciphey.Decryptor.Encoding.bases/Bases.decrypt
|
Modified
|
Ciphey~Ciphey
|
eb0c7f706710547a497dfc7fa2078f2f228e0fd8
|
Merge pull request #112 from Ciphey/testing
|
<7>:<add> self.ascii85(text)
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
<0> logger.debug("Attempting base decoding")
<1>
<2> bases = [
<3> self.base32(text),
<4> self.base16(text),
<5> self.base64(text),
<6> self.base85(text),
<7> ]
<8> for answer in bases:
<9> try:
<10> if answer["IsPlaintext?"]:
<11> # good answer
<12> logger.debug(f"Returning true for {answer}")
<13> return answer
<14> except TypeError:
<15> continue
<16> # Base85
<17> # if nothing works, it has failed.
<18> return self.badRet()
<19>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.bases.Bases
base64(text: str)
base32(text: str)
base16(text: str)
base85(text: str)
ascii85(text: str)
|
ciphey.Decryptor.Encoding.morsecode/MorseCode.__init__
|
Modified
|
Ciphey~Ciphey
|
eb0c7f706710547a497dfc7fa2078f2f228e0fd8
|
Merge pull request #112 from Ciphey/testing
|
<1>:<add> self.ALLOWED = {".", "-", " ", "/", "\n"}
<del> self.ALLOWED = [".", "-", " ", "/", "\n"]
|
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def __init__(self, lc):
<0> self.lc = lc
<1> self.ALLOWED = [".", "-", " ", "/", "\n"]
<2> self.MORSE_CODE_DICT = dict(cipheydists.get_charset("morse"))
<3> self.MORSE_CODE_DICT_INV = {v: k for k, v in self.MORSE_CODE_DICT.items()}
<4>
|
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def ascii85(self, text: str):
+ """Base85 decode
+
+ args:
+ text -> text to decode
+ returns:
+ the text decoded as base85
+ """
+ logger.trace("Attempting ascii85")
+ result = None
+ return self._dispatch(base64.a85decode, text, "base85")
+
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
+ self.ascii85(text)
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
|
ciphey.Decryptor.Encoding.morsecode/MorseCode.checkIfMorse
|
Modified
|
Ciphey~Ciphey
|
eb0c7f706710547a497dfc7fa2078f2f228e0fd8
|
Merge pull request #112 from Ciphey/testing
|
<0>:<add> count = 0
<add> for i in text:
<add> if i in self.ALLOWED:
<add> count += 1
<add> return count / len(text) > 0.625
<del> # return set(self.ALLOWED).issuperset(text)
<1>:<del> return "-" or "." in text
|
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def checkIfMorse(self, text):
<0> # return set(self.ALLOWED).issuperset(text)
<1> return "-" or "." in text
<2>
|
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def __init__(self, lc):
self.lc = lc
+ self.ALLOWED = {".", "-", " ", "/", "\n"}
- self.ALLOWED = [".", "-", " ", "/", "\n"]
self.MORSE_CODE_DICT = dict(cipheydists.get_charset("morse"))
self.MORSE_CODE_DICT_INV = {v: k for k, v in self.MORSE_CODE_DICT.items()}
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def ascii85(self, text: str):
+ """Base85 decode
+
+ args:
+ text -> text to decode
+ returns:
+ the text decoded as base85
+ """
+ logger.trace("Attempting ascii85")
+ result = None
+ return self._dispatch(base64.a85decode, text, "base85")
+
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
+ self.ascii85(text)
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
|
ciphey.Decryptor.Encoding.morsecode/MorseCode.unmorse_it
|
Modified
|
Ciphey~Ciphey
|
eb0c7f706710547a497dfc7fa2078f2f228e0fd8
|
Merge pull request #112 from Ciphey/testing
|
<12>:<del> print(returnMsg)
<13>:<add> return returnMsg.strip().upper()
<del> return returnMsg.strip().capitalize()
|
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def unmorse_it(self, text):
<0> returnMsg = ""
<1> for word in text.split("/"):
<2> for char in word.strip().split():
<3> # translates every letter
<4> try:
<5> m = self.MORSE_CODE_DICT_INV[char]
<6> except KeyError:
<7> m = ""
<8> returnMsg = returnMsg + m
<9> # after every word add a space
<10> # after every word add a space
<11> returnMsg = returnMsg + " "
<12> print(returnMsg)
<13> return returnMsg.strip().capitalize()
<14>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.morsecode.MorseCode.__init__
self.ALLOWED = {".", "-", " ", "/", "\n"}
self.MORSE_CODE_DICT_INV = {v: k for k, v in self.MORSE_CODE_DICT.items()}
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def checkIfMorse(self, text):
+ count = 0
+ for i in text:
+ if i in self.ALLOWED:
+ count += 1
+ return count / len(text) > 0.625
- # return set(self.ALLOWED).issuperset(text)
- return "-" or "." in text
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.morsecode
class MorseCode:
def __init__(self, lc):
self.lc = lc
+ self.ALLOWED = {".", "-", " ", "/", "\n"}
- self.ALLOWED = [".", "-", " ", "/", "\n"]
self.MORSE_CODE_DICT = dict(cipheydists.get_charset("morse"))
self.MORSE_CODE_DICT_INV = {v: k for k, v in self.MORSE_CODE_DICT.items()}
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def ascii85(self, text: str):
+ """Base85 decode
+
+ args:
+ text -> text to decode
+ returns:
+ the text decoded as base85
+ """
+ logger.trace("Attempting ascii85")
+ result = None
+ return self._dispatch(base64.a85decode, text, "base85")
+
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
+ self.ascii85(text)
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
3e3ca03e9e24b6e0e50d5798296a64b24c708c1b
|
Merge pull request #122 from Ciphey/cov-fixes
|
<15>:<del> print(f"Returning {self.text}")
|
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
<0> """Performs the decryption of text
<1>
<2> Creates the probability table, calls one_level_of_decryption
<3>
<4> Args:
<5> None, it uses class variables.
<6>
<7> Returns:
<8> None
<9> """
<10> # Read the documentation for more on this function.
<11> # checks to see if inputted text is plaintext
<12> result = self.lc.checkLanguage(self.text)
<13> if result:
<14> print("You inputted plain text!")
<15> print(f"Returning {self.text}")
<16> return {
<17> "lc": self.lc,
<18> "IsPlaintext?": True,
<19> "Plaintext": self.text,
<20> "Cipher": None,
<21> "Extra Information": None,
<22> }
<23> self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
<24> self.what_to_choose: dict = {
<25> self.hash: {
<26> "sha1": self.probability_distribution[0],
<27> "md5": self.probability_distribution[1],
<28> "sha256": self.probability_distribution[2],
<29> "sha512": self.probability_distribution[3],
<30> },
<31> self.basic: {"caesar": self.probability_distribution[4]},
<32> "plaintext": {"plaintext": self.probability_distribution[5]},
<33> self.encoding: {
<34> "reverse": self.probability_distribution[6],
<35> "base64": self.probability_distribution[7],
<36> "binary": self.probability_distribution[8],
<37> "hexadecimal": self.probability_distribution[9],
<38> "ascii": self.probability_distribution[10],
<39> "morse": self.probability_distribution[11],
<40> },
<41> }
<42>
<43> logger.trace(
<44> f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
<45> </s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.greppable:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
produceprobtable(prob_table) -> None
one_level_of_decryption() -> Optional[dict]
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
self.greppable: bool = config["grep"]
self.probability_distribution: dict = {}
at: ciphey.mathsHelper.mathsHelper
sort_prob_table(prob_table: dict) -> dict
at: neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
|
ciphey.__main__/Ciphey.decrypt_normal
|
Modified
|
Ciphey~Ciphey
|
3e3ca03e9e24b6e0e50d5798296a64b24c708c1b
|
Merge pull request #122 from Ciphey/cov-fixes
|
<33>:<add> logger.trace("Self.cipher_info runs")
|
# module: ciphey.__main__
class Ciphey:
def decrypt_normal(self, bar=None) -> Optional[dict]:
<0> """Called by one_level_of_decryption
<1>
<2> Performs a decryption, but mainly parses the internal data packet and prints useful information.
<3>
<4> Args:
<5> bar -> whether or not to use alive_Bar
<6>
<7> Returns:
<8> str if found, or None if not
<9>
<10> """
<11> # This is redundant
<12> # result = self.lc.checkLanguage(self.text)
<13> # if result:
<14> # print("You inputted plain text!")
<15> # print(f"Returning {self.text}")
<16> # return self.text
<17>
<18> logger.debug(f"In decrypt_normal")
<19> for key, val in self.what_to_choose.items():
<20> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<21> if not isinstance(key, str):
<22> key.setProbTable(val)
<23> ret: dict = key.decrypt(self.text)
<24> logger.debug(f"Decrypt normal in __main__ ret is {ret}")
<25> logger.debug(
<26> f"The plaintext is {ret['Plaintext']} and the extra information is {ret['Cipher']} and {ret['Extra Information']}"
<27> )
<28>
<29> if ret["IsPlaintext?"]:
<30> logger.debug(f"Ret is plaintext")
<31> print(ret["Plaintext"])
<32> if self.cipher_info:
<33> if ret["Extra Information"] is not None:
<34> print(
<35> "The cipher used is",
<36> ret["Cipher"] + ".",
<37> ret["Extra Information"] + ".",
<38> )
<39> else:
<40> print("The cipher used is " + ret["Cipher"] + ".")
<41> return ret
<42>
<43> logger.debug("No encryption found")
<44> print(
<45> """No encryption found. Here are some tips to help</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt_normal(self, bar=None) -> Optional[dict]:
# offset: 1
* Use the probability table to work out what it could be. Base = base16, base32, base64 etc.
* If the probability table says 'Caesar Cipher' then it is a normal encryption that \
Ciphey cannot decrypt yet.
* If Ciphey think's it's a hash, try using hash-identifier to find out what hash it is, \
and then HashCat to crack the hash.
* The encryption may not contain normal English plaintext. It could be coordinates or \
another object no found in the dictionary. Use 'ciphey -d true > log.txt' to generate a log \
file of all attempted decryptions and manually search it."""
)
return None
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey.__init__
self.text: str = config["ctext"]
self.cipher_info = config["info"]
self.what_to_choose: dict = {}
at: ciphey.__main__.Ciphey.decrypt
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
"""Performs the decryption of text
Creates the probability table, calls one_level_of_decryption
Args:
None, it uses class variables.
Returns:
None
"""
# Read the documentation for more on this function.
# checks to see if inputted text is plaintext
result = self.lc.checkLanguage(self.text)
if result:
print("You inputted plain text!")
- print(f"Returning {self.text}")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": self.text,
"Cipher": None,
"Extra Information": None,
}
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
logger.trace(
f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
)
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.items():
for k, v in value.items():
# Sets all 0</s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
<s>, value in self.what_to_choose.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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.greppable:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
|
ciphey.Decryptor.Encoding.bases/Bases.ascii85
|
Modified
|
Ciphey~Ciphey
|
cb872d4f3e514388a2943748899321ce18100028
|
Added base58 bitcoin version
|
<8>:<del> result = None
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def ascii85(self, text: str):
<0> """Base85 decode
<1>
<2> args:
<3> text -> text to decode
<4> returns:
<5> the text decoded as base85
<6> """
<7> logger.trace("Attempting ascii85")
<8> result = None
<9> return self._dispatch(base64.a85decode, text, "base85")
<10>
|
===========unchanged ref 0===========
at: base64
a85decode(b: _decodable, *, foldspaces: bool=..., adobe: bool=..., ignorechars: Union[str, bytes]=...) -> bytes
at: ciphey.Decryptor.Encoding.bases.Bases
_dispatch(decoder: Callable[[str], bytes], text: str, cipher: str)
|
ciphey.Decryptor.Encoding.bases/Bases.decrypt
|
Modified
|
Ciphey~Ciphey
|
b986f6c26c5adbda54bacac4496497a155a70421
|
Added Base58 decoding tests
|
<8>:<add> self.base85_bitcoin(text),
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
<0> logger.debug("Attempting base decoding")
<1>
<2> bases = [
<3> self.base32(text),
<4> self.base16(text),
<5> self.base64(text),
<6> self.base85(text),
<7> self.ascii85(text),
<8> ]
<9> for answer in bases:
<10> try:
<11> if answer["IsPlaintext?"]:
<12> # good answer
<13> logger.debug(f"Returning true for {answer}")
<14> return answer
<15> except TypeError:
<16> continue
<17> # Base85
<18> # if nothing works, it has failed.
<19> return self.badRet()
<20>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.bases.Bases
base64(text: str)
base32(text: str)
base16(text: str)
base85(text: str)
ascii85(text: str)
base85_bitcoin(text: str)
|
tests.enciphey/encipher_crypto.__init__
|
Modified
|
Ciphey~Ciphey
|
b986f6c26c5adbda54bacac4496497a155a70421
|
Added Base58 decoding tests
|
<10>:<add> self.base58_bitcoin,
<add> self.base58_ripple,
|
# module: tests.enciphey
class encipher_crypto:
def __init__(self):
<0> self.methods = [
<1> self.Base64,
<2> self.Ascii,
<3> self.Base16,
<4> self.Base32,
<5> self.Binary,
<6> self.Hex,
<7> self.MorseCode,
<8> self.Reverse,
<9> self.Vigenere,
<10> ]
<11> self.morse_dict = dict(cipheydists.get_charset("morse"))
<12> self.letters = string.ascii_lowercase
<13> self.group = cipheydists.get_charset("english")["lcase"]
<14>
|
===========unchanged ref 0===========
at: tests.enciphey.encipher_crypto
Base64(text: str) -> str
Base32(text: str) -> str
Base16(text: str) -> str
Binary(text: str) -> str
Ascii(text: str) -> str
Hex(text: str) -> str
MorseCode(text: str) -> str
Reverse(text: str) -> str
Vigenere(plaintext)
base58_bitcoin(text: str)
base58_ripple(text: str)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
self.ascii85(text),
+ self.base85_bitcoin(text),
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
|
ciphey.Decryptor.Encoding.bases/Bases.decrypt
|
Modified
|
Ciphey~Ciphey
|
5e2e74381e9ae43798f3fd8c967c03183b6203db
|
Added base62
|
<9>:<add> self.b62(text),
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
<0> logger.debug("Attempting base decoding")
<1>
<2> bases = [
<3> self.base32(text),
<4> self.base16(text),
<5> self.base64(text),
<6> self.base85(text),
<7> self.ascii85(text),
<8> self.base85_bitcoin(text),
<9> ]
<10> for answer in bases:
<11> try:
<12> if answer["IsPlaintext?"]:
<13> # good answer
<14> logger.debug(f"Returning true for {answer}")
<15> return answer
<16> except TypeError:
<17> continue
<18> # Base85
<19> # if nothing works, it has failed.
<20> return self.badRet()
<21>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.bases.Bases
base64(text: str)
base32(text: str)
base16(text: str)
base85(text: str)
ascii85(text: str)
base85_bitcoin(text: str)
b62(text: str)
|
tests.enciphey/encipher_crypto.__init__
|
Modified
|
Ciphey~Ciphey
|
399cc7a12a0f0f018a59abf6651b61e3b66582f0
|
Added tests
|
<12>:<add> self.b62,
|
# module: tests.enciphey
class encipher_crypto:
def __init__(self):
<0> self.methods = [
<1> self.Base64,
<2> self.Ascii,
<3> self.Base16,
<4> self.Base32,
<5> self.Binary,
<6> self.Hex,
<7> self.MorseCode,
<8> self.Reverse,
<9> self.Vigenere,
<10> self.base58_bitcoin,
<11> self.base58_ripple,
<12> ]
<13> self.morse_dict = dict(cipheydists.get_charset("morse"))
<14> self.letters = string.ascii_lowercase
<15> self.group = cipheydists.get_charset("english")["lcase"]
<16>
|
===========unchanged ref 0===========
at: string
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
at: tests.enciphey.encipher_crypto
Base64(text: str) -> str
Base32(text: str) -> str
Base16(text: str) -> str
Binary(text: str) -> str
Ascii(text: str) -> str
Hex(text: str) -> str
MorseCode(text: str) -> str
Reverse(text: str) -> str
Vigenere(plaintext)
base58_bitcoin(text: str)
base58_ripple(text: str)
b62(text: str)
|
tests.generate_tests/test_generator.__init__
|
Modified
|
Ciphey~Ciphey
|
4b1247d117b6ec2699d02654327c35ce77f87579
|
Updated .gitignore to ignore test generation
|
<0>:<add> self.HOW_MANY_TESTS = 30
<del> self.HOW_MANY_TESTS = 2
|
# module: tests.generate_tests
class test_generator:
def __init__(self):
<0> self.HOW_MANY_TESTS = 2
<1> self.enCiphey_obj = enciphey.encipher()
<2>
|
===========unchanged ref 0===========
at: enciphey
encipher()
|
tests.enciphey/encipher_crypto.b62
|
Modified
|
Ciphey~Ciphey
|
4b1247d117b6ec2699d02654327c35ce77f87579
|
Updated .gitignore to ignore test generation
|
<0>:<add> return base62.decode(str(re.sub(r"\W+", "", text)))
<del> return base62.encode(bytes(text, "utf-8")).decode("utf-8")
|
# module: tests.enciphey
class encipher_crypto:
def b62(self, text: str):
<0> return base62.encode(bytes(text, "utf-8")).decode("utf-8")
<1>
|
===========changed ref 0===========
# module: tests.generate_tests
class test_generator:
def __init__(self):
+ self.HOW_MANY_TESTS = 30
- self.HOW_MANY_TESTS = 2
self.enCiphey_obj = enciphey.encipher()
|
ciphey.__main__/Ciphey.__init__
|
Modified
|
Ciphey~Ciphey
|
2cfb0dcf7c0f5696fbabdeb8f939515dc44dee37
|
Ceaned up arg parsing
|
<15>:<add>
<add> self.config = config
<add>
<del> self.greppable: bool = config["grep"]
<16>:<del> self.cipher_info = config["info"]
|
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
<0> logger.remove()
<1> logger.configure()
<2> logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
<3> logger.opt(colors=True)
<4> logger.debug(f"""Debug level set to {config["debug"]}""")
<5> # general purpose modules
<6> self.ai = NeuralNetwork()
<7> self.lc = config["checker"](config)
<8> self.mh = mh.mathsHelper()
<9> # the one bit of text given to us to decrypt
<10> self.text: str = config["ctext"]
<11> self.basic = BasicParent(self.lc)
<12> self.hash = HashParent(self.lc)
<13> self.encoding = EncodingParent(self.lc)
<14> self.level: int = 1
<15> self.greppable: bool = config["grep"]
<16> self.cipher_info = config["info"]
<17> self.console = Console()
<18> self.probability_distribution: dict = {}
<19> self.what_to_choose: dict = {}
<20>
|
===========unchanged ref 0===========
at: Decryptor.Encoding.encodingParent
EncodingParent(lc)
at: Decryptor.basicEncryption.basic_parent
BasicParent(lc)
at: ciphey.Decryptor.Hash.hashParent
HashParent(lc)
at: ciphey.__main__.Ciphey.decrypt
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
at: ciphey.mathsHelper
mathsHelper()
at: ciphey.neuralNetworkMod.nn
NeuralNetwork()
at: sys
stderr: TextIO
at: typing.IO
__slots__ = ()
isatty() -> bool
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
2cfb0dcf7c0f5696fbabdeb8f939515dc44dee37
|
Ceaned up arg parsing
|
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
<0> """Performs the decryption of text
<1>
<2> Creates the probability table, calls one_level_of_decryption
<3>
<4> Args:
<5> None, it uses class variables.
<6>
<7> Returns:
<8> None
<9> """
<10> # Read the documentation for more on this function.
<11> # checks to see if inputted text is plaintext
<12> result = self.lc.checkLanguage(self.text)
<13> if result:
<14> print("You inputted plain text!")
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": True,
<18> "Plaintext": self.text,
<19> "Cipher": None,
<20> "Extra Information": None,
<21> }
<22> self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
<23> self.what_to_choose: dict = {
<24> self.hash: {
<25> "sha1": self.probability_distribution[0],
<26> "md5": self.probability_distribution[1],
<27> "sha256": self.probability_distribution[2],
<28> "sha512": self.probability_distribution[3],
<29> },
<30> self.basic: {"caesar": self.probability_distribution[4]},
<31> "plaintext": {"plaintext": self.probability_distribution[5]},
<32> self.encoding: {
<33> "reverse": self.probability_distribution[6],
<34> "base64": self.probability_distribution[7],
<35> "binary": self.probability_distribution[8],
<36> "hexadecimal": self.probability_distribution[9],
<37> "ascii": self.probability_distribution[10],
<38> "morse": self.probability_distribution[11],
<39> },
<40> }
<41>
<42> logger.trace(
<43> f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
<44> )
<45>
<46> # sorts each individual sub-dictionary
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.greppable:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
produceprobtable(prob_table) -> None
one_level_of_decryption() -> Optional[dict]
one_level_of_decryption(self) -> Optional[dict]
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
self.config = config
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
at: ciphey.neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
at: mathsHelper.mathsHelper
sort_prob_table(prob_table: dict) -> dict
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
logger.remove()
logger.configure()
logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
logger.opt(colors=True)
logger.debug(f"""Debug level set to {config["debug"]}""")
# general purpose modules
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
+
+ self.config = config
+
- self.greppable: bool = config["grep"]
- self.cipher_info = config["info"]
self.console = Console()
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
|
|
ciphey.__main__/Ciphey.one_level_of_decryption
|
Modified
|
Ciphey~Ciphey
|
2cfb0dcf7c0f5696fbabdeb8f939515dc44dee37
|
Ceaned up arg parsing
|
<11>:<add> if self.config["grep"]:
<del> if self.greppable:
|
# module: ciphey.__main__
class Ciphey:
def one_level_of_decryption(self) -> Optional[dict]:
<0> """Performs one level of encryption.
<1>
<2> Either uses alive_bar or not depending on if self.greppable is set.
<3>
<4> Returns:
<5> None.
<6>
<7> """
<8> # Calls one level of decryption
<9> # mainly used to control the progress bar
<10> output = None
<11> if self.greppable:
<12> logger.debug("__main__ is running as greppable")
<13> output = self.decrypt_normal()
<14> else:
<15> logger.debug("__main__ is running with progress bar")
<16> output = self.decrypt_normal()
<17> return output
<18>
|
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
decrypt_normal(bar=None) -> Optional[dict]
decrypt_normal(self, bar=None) -> Optional[dict]
at: ciphey.__main__.Ciphey.__init__
self.config = config
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
logger.remove()
logger.configure()
logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
logger.opt(colors=True)
logger.debug(f"""Debug level set to {config["debug"]}""")
# general purpose modules
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
+
+ self.config = config
+
- self.greppable: bool = config["grep"]
- self.cipher_info = config["info"]
self.console = Console()
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
"""Performs the decryption of text
Creates the probability table, calls one_level_of_decryption
Args:
None, it uses class variables.
Returns:
None
"""
# Read the documentation for more on this function.
# checks to see if inputted text is plaintext
result = self.lc.checkLanguage(self.text)
if result:
print("You inputted plain text!")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": self.text,
"Cipher": None,
"Extra Information": None,
}
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
logger.trace(
f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
)
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all</s>
===========changed ref 2===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
<s> 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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
+ if not self.config["grep"]:
- if not self.greppable:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
|
ciphey.__main__/Ciphey.decrypt_normal
|
Modified
|
Ciphey~Ciphey
|
2cfb0dcf7c0f5696fbabdeb8f939515dc44dee37
|
Ceaned up arg parsing
|
<32>:<add> if self.config["info"]:
<del> if self.cipher_info:
|
# module: ciphey.__main__
class Ciphey:
def decrypt_normal(self, bar=None) -> Optional[dict]:
<0> """Called by one_level_of_decryption
<1>
<2> Performs a decryption, but mainly parses the internal data packet and prints useful information.
<3>
<4> Args:
<5> bar -> whether or not to use alive_Bar
<6>
<7> Returns:
<8> str if found, or None if not
<9>
<10> """
<11> # This is redundant
<12> # result = self.lc.checkLanguage(self.text)
<13> # if result:
<14> # print("You inputted plain text!")
<15> # print(f"Returning {self.text}")
<16> # return self.text
<17>
<18> logger.debug(f"In decrypt_normal")
<19> for key, val in self.what_to_choose.items():
<20> # https://stackoverflow.com/questions/4843173/how-to-check-if-type-of-a-variable-is-string
<21> if not isinstance(key, str):
<22> key.setProbTable(val)
<23> ret: dict = key.decrypt(self.text)
<24> logger.debug(f"Decrypt normal in __main__ ret is {ret}")
<25> logger.debug(
<26> f"The plaintext is {ret['Plaintext']} and the extra information is {ret['Cipher']} and {ret['Extra Information']}"
<27> )
<28>
<29> if ret["IsPlaintext?"]:
<30> logger.debug(f"Ret is plaintext")
<31> print(ret["Plaintext"])
<32> if self.cipher_info:
<33> logger.trace("Self.cipher_info runs")
<34> if ret["Extra Information"] is not None:
<35> print(
<36> "The cipher used is",
<37> ret["Cipher"] + ".",
<38> ret["Extra Information"] + ".",
<39> )
<40> else:
<41> print("The cipher used is " + ret["Cipher"] + ".")
<42> return ret
<43>
<44> logger.debug("No encryption found")
<45> print(</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt_normal(self, bar=None) -> Optional[dict]:
# offset: 1
* Use the probability table to work out what it could be. Base = base16, base32, base64 etc.
* If the probability table says 'Caesar Cipher' then it is a normal encryption that \
Ciphey cannot decrypt yet.
* If Ciphey think's it's a hash, try using hash-identifier to find out what hash it is, \
and then HashCat to crack the hash.
* The encryption may not contain normal English plaintext. It could be coordinates or \
another object no found in the dictionary. Use 'ciphey -d true > log.txt' to generate a log \
file of all attempted decryptions and manually search it."""
)
return None
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey.__init__
self.text: str = config["ctext"]
self.config = config
self.what_to_choose: dict = {}
at: ciphey.__main__.Ciphey.decrypt
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def one_level_of_decryption(self) -> Optional[dict]:
"""Performs one level of encryption.
Either uses alive_bar or not depending on if self.greppable is set.
Returns:
None.
"""
# Calls one level of decryption
# mainly used to control the progress bar
output = None
+ if self.config["grep"]:
- if self.greppable:
logger.debug("__main__ is running as greppable")
output = self.decrypt_normal()
else:
logger.debug("__main__ is running with progress bar")
output = self.decrypt_normal()
return output
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
logger.remove()
logger.configure()
logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
logger.opt(colors=True)
logger.debug(f"""Debug level set to {config["debug"]}""")
# general purpose modules
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
+
+ self.config = config
+
- self.greppable: bool = config["grep"]
- self.cipher_info = config["info"]
self.console = Console()
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
===========changed ref 2===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
"""Performs the decryption of text
Creates the probability table, calls one_level_of_decryption
Args:
None, it uses class variables.
Returns:
None
"""
# Read the documentation for more on this function.
# checks to see if inputted text is plaintext
result = self.lc.checkLanguage(self.text)
if result:
print("You inputted plain text!")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": self.text,
"Cipher": None,
"Extra Information": None,
}
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
logger.trace(
f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
)
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all</s>
===========changed ref 3===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
<s> 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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
+ if not self.config["grep"]:
- if not self.greppable:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
2cfb0dcf7c0f5696fbabdeb8f939515dc44dee37
|
Ceaned up arg parsing
|
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7> parser = argparse.ArgumentParser(
<8> description="""Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it.\n
<9> Examples:
<10> python3 ciphey -t "aGVsbG8gbXkgYmFieQ==" -d true -c true
<11> """
<12> )
<13> parser.add_argument(
<14> "-g",
<15> "--greppable",
<16> help="Only output the answer, no progress bars or information. Useful for grep",
<17> action="store_true",
<18> required=False,
<19> default=False,
<20> )
<21> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<22> parser.add_argument(
<23> "-i",
<24> "--info",
<25> help="Do you want information on the cipher used?",
<26> action="store_true",
<27> required=False,
<28> default=False,
<29> )
<30> parser.add_argument(
<31> "-d",
<32> "--debug",
<33> help="Activates debug mode", # Actually "INFO" level is used, but ¯\_(ツ)_/¯
<34> required=False,
<35> action="store_true",
<36> )
<37> parser.add_argument(
<38> "-D",
<39> "--trace",
<40> help="More verbose than debug mode. Shadows --debug",
<41> required=False,
<42> action="store_true",
<43> )
<44> parser.add_argument(
<45> "-q", "--quiet", help="Supress warnings", required=False, action="store_true",
<46> )
<47> parser.add_argument(
<48> "-a",
<49> "--checker",
<50> help="Uses the given internal language checker. Defaults to brandon",
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 1
)
parser.add_argument(
"-A",
"--checker-file",
help="Uses the language checker at the given path",
required=False,
)
parser.add_argument(
"-w", "--wordlist", help="Uses the given internal wordlist", required=False,
)
parser.add_argument(
"-W",
"--wordlist-file",
help="Uses the wordlist at the given path",
required=False,
)
parser.add_argument(
"-p",
"--param",
help="Passes a parameter to the language checker",
action="append",
required=False,
default=[],
)
parser.add_argument(
"-l",
"--list-params",
help="Lists the parameters of the selected module",
action="store_true",
required=False,
)
parser.add_argument("rest", nargs=argparse.REMAINDER)
args = vars(parser.parse_args())
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
elif len(sys.argv) > 1:
text = args["rest"][0]
elif not sys.stdin.isatty():
text = str(sys.stdin.read())
else:
print("No text input given!")
return None
if len(sys.argv) == 1:
print("No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")</s>
===========below chunk 1===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 2
<s>
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
# Try to work out how verbose we should be
if args["trace"]:
config["debug"] = "TRACE"
elif args["debug"]:
config["debug"] = "DEBUG"
elif args["quiet"]:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: argparse
REMAINDER = '...'
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.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: sys
argv: List[str]
stdin: TextIO
at: typing.IO
isatty() -> bool
read(n: int=...) -> AnyStr
at: typing.MutableMapping
pop(key: _KT, default: Union[_VT, _T]=...) -> Union[_VT, _T]
pop(key: _KT) -> _VT
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def one_level_of_decryption(self) -> Optional[dict]:
"""Performs one level of encryption.
Either uses alive_bar or not depending on if self.greppable is set.
Returns:
None.
"""
# Calls one level of decryption
# mainly used to control the progress bar
output = None
+ if self.config["grep"]:
- if self.greppable:
logger.debug("__main__ is running as greppable")
output = self.decrypt_normal()
else:
logger.debug("__main__ is running with progress bar")
output = self.decrypt_normal()
return output
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def __init__(self, config):
logger.remove()
logger.configure()
logger.add(sink=sys.stderr, level=config["debug"], colorize=sys.stderr.isatty())
logger.opt(colors=True)
logger.debug(f"""Debug level set to {config["debug"]}""")
# general purpose modules
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
# the one bit of text given to us to decrypt
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
+
+ self.config = config
+
- self.greppable: bool = config["grep"]
- self.cipher_info = config["info"]
self.console = Console()
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
|
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
7e109d483377f2b14f953171d8459613ae161b68
|
Added offline mode, fixed up argument parsing
|
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
<0> """Performs the decryption of text
<1>
<2> Creates the probability table, calls one_level_of_decryption
<3>
<4> Args:
<5> None, it uses class variables.
<6>
<7> Returns:
<8> None
<9> """
<10> # Read the documentation for more on this function.
<11> # checks to see if inputted text is plaintext
<12> result = self.lc.checkLanguage(self.text)
<13> if result:
<14> print("You inputted plain text!")
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": True,
<18> "Plaintext": self.text,
<19> "Cipher": None,
<20> "Extra Information": None,
<21> }
<22> self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
<23> self.what_to_choose: dict = {
<24> self.hash: {
<25> "sha1": self.probability_distribution[0],
<26> "md5": self.probability_distribution[1],
<27> "sha256": self.probability_distribution[2],
<28> "sha512": self.probability_distribution[3],
<29> },
<30> self.basic: {"caesar": self.probability_distribution[4]},
<31> "plaintext": {"plaintext": self.probability_distribution[5]},
<32> self.encoding: {
<33> "reverse": self.probability_distribution[6],
<34> "base64": self.probability_distribution[7],
<35> "binary": self.probability_distribution[8],
<36> "hexadecimal": self.probability_distribution[9],
<37> "ascii": self.probability_distribution[10],
<38> "morse": self.probability_distribution[11],
<39> },
<40> }
<41>
<42> logger.trace(
<43> f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
<44> )
<45>
<46> # sorts each individual sub-dictionary
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
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.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.config["grep"]:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
produceprobtable(prob_table) -> None
produceprobtable(self, prob_table) -> None
one_level_of_decryption() -> Optional[dict]
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
self.config = config
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
at: ciphey.neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
at: mathsHelper.mathsHelper
sort_prob_table(prob_table: dict) -> dict
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+
+ def __name__(self):
+ return "hashParent"
+
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
+
+ def __name__(self):
+ return "encodingParent"
+
===========changed ref 2===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
+ def __name__(self):
+ return "basicParent"
+
|
|
ciphey.__main__/Ciphey.produceprobtable
|
Modified
|
Ciphey~Ciphey
|
7e109d483377f2b14f953171d8459613ae161b68
|
Added offline mode, fixed up argument parsing
|
<22>:<add> if value <= 0.01:
<del> if value == 0.01:
|
# module: ciphey.__main__
class Ciphey:
def produceprobtable(self, prob_table) -> None:
<0> """Produces the probability table using Rich's API
<1>
<2> Uses Rich's API to print the probability table.
<3>
<4> Args:
<5> prob_table -> the probability table generated by the neural network
<6>
<7> Returns:
<8> None, but prints the probability table.
<9>
<10> """
<11> logger.debug(f"Producing log table")
<12> table = Table(show_header=True, header_style="bold magenta")
<13> table.add_column("Name of Cipher")
<14> table.add_column("Probability", justify="right")
<15> # for every key, value in dict add a row
<16> # I think key is self.caesarcipher and not "caesar cipher"
<17> # i must callName() somewhere else in this code
<18> sorted_dic: dict = {}
<19> for k, v in prob_table.items():
<20> for key, value in v.items():
<21> # Prevents the table from showing pointless 0.01 probs as they're faked
<22> if value == 0.01:
<23> continue
<24> # gets the string ready to print
<25> logger.debug(f"Key is {str(key)} and value is {str(value)}")
<26> val: int = round(self.mh.percentage(value, 1), 2)
<27> key_str: str = str(key).capitalize()
<28> # converts "Bases" to "Base"
<29> if "Base" in key_str:
<30> key_str = key_str[0:-2]
<31> sorted_dic[key_str] = val
<32> logger.debug(f"The value as percentage is {val} and key is {key_str}")
<33> sorted_dic: dict = {
<34> k: v
<35> for k, v in sorted(
<36> sorted_dic.items(), key=lambda item: item[1], reverse=True
<37> )
<38> }
<39> for k, v in sorted_dic</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def produceprobtable(self, prob_table) -> None:
# offset: 1
table.add_row(k, str(v) + "%")
self.console.print(table)
return None
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey.__init__
self.mh = mh.mathsHelper()
at: ciphey.__main__.Ciphey.decrypt
output = None
output = self.one_level_of_decryption()
output = self.one_level_of_decryption(file=f)
at: mathsHelper.mathsHelper
percentage(part: float, whole: float) -> float
===========changed ref 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
"""Performs the decryption of text
Creates the probability table, calls one_level_of_decryption
Args:
None, it uses class variables.
Returns:
None
"""
# Read the documentation for more on this function.
# checks to see if inputted text is plaintext
result = self.lc.checkLanguage(self.text)
if result:
print("You inputted plain text!")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": self.text,
"Cipher": None,
"Extra Information": None,
}
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
logger.trace(
f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
)
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all</s>
===========changed ref 1===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
<s> for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
+ # this should turn off hashing functions if offline mode is turned on
+ if self.config["offline"]:
+ if key.__name__() == "hashParent":
+ continue
self.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.config["grep"]:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
===========changed ref 2===========
# module: ciphey.Decryptor.Hash.hashParent
class HashParent:
+
+ def __name__(self):
+ return "hashParent"
+
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
+
+ def __name__(self):
+ return "encodingParent"
+
===========changed ref 4===========
# module: ciphey.Decryptor.basicEncryption.basic_parent
class BasicParent:
+ def __name__(self):
+ return "basicParent"
+
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
7e109d483377f2b14f953171d8459613ae161b68
|
Added offline mode, fixed up argument parsing
|
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7> parser = argparse.ArgumentParser(
<8> description="""Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it.\n
<9> Examples:
<10> python3 ciphey -t "aGVsbG8gbXkgYmFieQ==" -d true -c true
<11> """
<12> )
<13> parser.add_argument(
<14> "-g",
<15> "--greppable",
<16> help="Only output the answer, no progress bars or information. Useful for grep",
<17> action="store_true",
<18> required=False,
<19> default=False,
<20> )
<21> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<22> parser.add_argument(
<23> "-i",
<24> "--info",
<25> help="Do you want information on the cipher used?",
<26> action="store_true",
<27> required=False,
<28> default=False,
<29> )
<30> parser.add_argument(
<31> "-d",
<32> "--debug",
<33> help="Activates debug mode", # Actually "INFO" level is used, but ¯\_(ツ)_/¯
<34> required=False,
<35> action="store_true",
<36> )
<37> parser.add_argument(
<38> "-D",
<39> "--trace",
<40> help="More verbose than debug mode. Shadows --debug",
<41> required=False,
<42> action="store_true",
<43> )
<44> parser.add_argument(
<45> "-q", "--quiet", help="Supress warnings", required=False, action="store_true",
<46> )
<47> parser.add_argument(
<48> "-a",
<49> "--checker",
<50> help="Uses the given internal language checker. Defaults to brandon",
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 1
)
parser.add_argument(
"-A",
"--checker-file",
help="Uses the language checker at the given path",
required=False,
)
parser.add_argument(
"-w", "--wordlist", help="Uses the given internal wordlist", required=False,
)
parser.add_argument(
"-W",
"--wordlist-file",
help="Uses the wordlist at the given path",
required=False,
)
parser.add_argument(
"-p",
"--param",
help="Passes a parameter to the language checker",
action="append",
required=False,
default=[],
)
parser.add_argument(
"-l",
"--list-params",
help="Lists the parameters of the selected module",
action="store_true",
required=False,
)
parser.add_argument(
"-O",
"--offline",
help="Run Ciphey in offline mode (No hash support)",
action="store_true",
required="False",
)
parser.add_argument("rest", nargs=argparse.REMAINDER)
args = vars(parser.parse_args())
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
elif len(sys.argv) > 1:
text = args["rest"][0]
elif not sys.stdin.isatty():
text = str(sys.stdin.read())
else:
print("No text input given!")
return None
if len(sys.argv)</s>
===========below chunk 1===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 2
<s>read())
else:
print("No text input given!")
return None
if len(sys.argv) == 1:
print("No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
# Try to work out how verbose we should be
if args["trace"]:
config["debug"] = "TRACE"
elif args["debug"]:
config["debug"] = "DEBUG"
elif args["quiet"]:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: argparse
REMAINDER = '...'
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.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: sys
argv: List[str]
stdin: TextIO
at: typing.IO
__slots__ = ()
isatty() -> bool
read(n: int=...) -> AnyStr
at: typing.MutableMapping
pop(key: _KT, default: Union[_VT, _T]=...) -> Union[_VT, _T]
pop(key: _KT) -> _VT
|
|
tests.generate_tests/test_generator.make_test_true_template
|
Modified
|
Ciphey~Ciphey
|
6a475c26aee21fc5b3132e84629f6737e765887c
|
Fixing tests
|
<4>:<add> res = ciphey.main('''{cipher['Encrypted Texts']['EncryptedText']}''', config={"offline": True})
<del> res = ciphey.main('''{cipher['Encrypted Texts']['EncryptedText']}''')
|
# module: tests.generate_tests
class test_generator:
def make_test_true_template(self, cipher):
<0> id = self.randomString(8)
<1> return f"""
<2> def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
<3> # {cipher}
<4> res = ciphey.main('''{cipher['Encrypted Texts']['EncryptedText']}''')
<5> assert(res == {cipher['Encrypted Texts']['PlainText']})
<6> """
<7>
|
===========unchanged ref 0===========
at: tests.generate_tests.test_generator
randomString(stringLength)
|
tests.enciphey/encipher_crypto.b62
|
Modified
|
Ciphey~Ciphey
|
6a475c26aee21fc5b3132e84629f6737e765887c
|
Fixing tests
|
<0>:<add> return base62.decode(str(re.sub(r"[A=za=z]+", "", text)))
<del> return base62.decode(str(re.sub(r"\W+", "", text)))
|
# module: tests.enciphey
class encipher_crypto:
def b62(self, text: str):
<0> return base62.decode(str(re.sub(r"\W+", "", text)))
<1>
|
===========unchanged ref 0===========
at: re
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
===========changed ref 0===========
# module: tests.generate_tests
class test_generator:
def make_test_true_template(self, cipher):
id = self.randomString(8)
return f"""
def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
# {cipher}
+ res = ciphey.main('''{cipher['Encrypted Texts']['EncryptedText']}''', config={"offline": True})
- res = ciphey.main('''{cipher['Encrypted Texts']['EncryptedText']}''')
assert(res == {cipher['Encrypted Texts']['PlainText']})
"""
|
tests.generate_tests/test_generator.make_test_lc_true_template
|
Modified
|
Ciphey~Ciphey
|
c1b75ab68cf99d19242147abb38b1a9b8918d3f9
|
Why am I alive? Just to suffer?
|
<4>:<add> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
<del> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}''')
<6>:<add> result = main(cfg, config=\{'offline': True\})
<del> result = main(cfg)
|
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
<0> id = self.randomString(8)
<1> return f"""
<2> def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
<3> # {cipher}
<4> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}''')
<5> cfg["debug"] = "TRACE"
<6> result = main(cfg)
<7>
<8> assert result["IsPlaintext?"] == True
<9> """
<10>
|
===========unchanged ref 0===========
at: tests.generate_tests.test_generator
randomString(stringLength)
|
tests.enciphey/encipher_crypto.b62
|
Modified
|
Ciphey~Ciphey
|
c1b75ab68cf99d19242147abb38b1a9b8918d3f9
|
Why am I alive? Just to suffer?
|
<0>:<add> return base62.decode(str(re.sub(r"[A-za_z]+", "", text)))
<del> return base62.decode(str(re.sub(r"[A=za=z]+", "", text)))
|
# module: tests.enciphey
class encipher_crypto:
def b62(self, text: str):
<0> return base62.decode(str(re.sub(r"[A=za=z]+", "", text)))
<1>
|
===========unchanged ref 0===========
at: re
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
===========changed ref 0===========
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
id = self.randomString(8)
return f"""
def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
# {cipher}
+ cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
- cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}''')
cfg["debug"] = "TRACE"
+ result = main(cfg, config=\{'offline': True\})
- result = main(cfg)
assert result["IsPlaintext?"] == True
"""
|
tests.generate_tests/test_generator.make_test_lc_true_template
|
Modified
|
Ciphey~Ciphey
|
952c3dca3655a0c705a2c2d82aa39c944c8ec004
|
Base62 test generation finally works
|
<6>:<add> result = main(cfg, config={{'offline': True}})
<del> result = main(cfg, config=\{'offline': True\})
|
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
<0> id = self.randomString(8)
<1> return f"""
<2> def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
<3> # {cipher}
<4> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
<5> cfg["debug"] = "TRACE"
<6> result = main(cfg, config=\{'offline': True\})
<7>
<8> assert result["IsPlaintext?"] == True
<9> """
<10>
|
===========unchanged ref 0===========
at: tests.generate_tests.test_generator
randomString(stringLength)
|
tests.enciphey/encipher_crypto.b62
|
Modified
|
Ciphey~Ciphey
|
952c3dca3655a0c705a2c2d82aa39c944c8ec004
|
Base62 test generation finally works
|
<0>:<add> return base62.decode(str(re.sub(r"[^A-Za-z1-9]+", "", text)))
<del> return base62.decode(str(re.sub(r"[A-za_z]+", "", text)))
|
# module: tests.enciphey
class encipher_crypto:
def b62(self, text: str):
<0> return base62.decode(str(re.sub(r"[A-za_z]+", "", text)))
<1>
|
===========unchanged ref 0===========
at: re
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
===========changed ref 0===========
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
id = self.randomString(8)
return f"""
def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
# {cipher}
cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
cfg["debug"] = "TRACE"
+ result = main(cfg, config={{'offline': True}})
- result = main(cfg, config=\{'offline': True\})
assert result["IsPlaintext?"] == True
"""
|
ciphey.Decryptor.Encoding.bases/Bases.decrypt
|
Modified
|
Ciphey~Ciphey
|
4885f64c2a838cde6a5f579534f4c581098d32b1
|
Honestly this might work but im not too sure
|
<8>:<add> self.base58_bitcoin(text),
<del> self.base85_bitcoin(text),
<9>:<add> self.base58_ripple(text, alphabet=base58.RIPPLE_ALPHABET),
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
<0> logger.debug("Attempting base decoding")
<1>
<2> bases = [
<3> self.base32(text),
<4> self.base16(text),
<5> self.base64(text),
<6> self.base85(text),
<7> self.ascii85(text),
<8> self.base85_bitcoin(text),
<9> self.b62(text),
<10> ]
<11> for answer in bases:
<12> try:
<13> if answer["IsPlaintext?"]:
<14> # good answer
<15> logger.debug(f"Returning true for {answer}")
<16> return answer
<17> except TypeError:
<18> continue
<19> # Base85
<20> # if nothing works, it has failed.
<21> return self.badRet()
<22>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.bases.Bases
base64(text: str)
base32(text: str)
base16(text: str)
base85(text: str)
ascii85(text: str)
base58_bitcoin(text: str)
base58_ripple(text: str, alphabet: str)
b62(text: str)
|
ciphey.Decryptor.Encoding.bases/Bases._dispatch
|
Modified
|
Ciphey~Ciphey
|
4885f64c2a838cde6a5f579534f4c581098d32b1
|
Honestly this might work but im not too sure
|
<3>:<add> result = decoder(text) if not alphabet else decoder(text, alphabet)
<del> result = decoder(text)
|
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def _dispatch(
+ self, decoder: Callable[[str], bytes], text: str, cipher: str, alphabet=None
- def _dispatch(self, decoder: Callable[[str], bytes], text: str, cipher: str):
+ ):
<0> logger.trace("Attempting base64")
<1> result = None
<2> try:
<3> result = decoder(text)
<4> # yeet turning b strings into normal stringy bois
<5> result = result.decode("utf-8")
<6> except UnicodeDecodeError as e:
<7> logger.trace("Bad unicode")
<8> result = None
<9> except binascii.Error as e:
<10> logger.trace("binascii error")
<11> result = None
<12> except ValueError:
<13> logger.trace("Failed to decode base")
<14> result = None
<15> except:
<16> logger.trace("Failed to decode base")
<17> result = None
<18>
<19> if result is not None and self.lc.checkLanguage(result):
<20> logger.debug(f"Bases successful, returning {result}")
<21> return self.goodRet(result, cipher=cipher)
<22> else:
<23> return self.badRet()
<24>
|
===========unchanged ref 0===========
at: binascii
Error(*args: object)
at: ciphey.Decryptor.Encoding.bases.Bases.__init__
self.lc = lc
at: ciphey.LanguageChecker.brandon.Brandon
wordlist: set
checkLanguage(text: str) -> bool
at: typing
Callable = _CallableType(collections.abc.Callable, 2)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
self.ascii85(text),
+ self.base58_bitcoin(text),
- self.base85_bitcoin(text),
+ self.base58_ripple(text, alphabet=base58.RIPPLE_ALPHABET),
self.b62(text),
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
|
ciphey.__main__/Ciphey.decrypt
|
Modified
|
Ciphey~Ciphey
|
4885f64c2a838cde6a5f579534f4c581098d32b1
|
Honestly this might work but im not too sure
|
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
<0> """Performs the decryption of text
<1>
<2> Creates the probability table, calls one_level_of_decryption
<3>
<4> Args:
<5> None, it uses class variables.
<6>
<7> Returns:
<8> None
<9> """
<10> # Read the documentation for more on this function.
<11> # checks to see if inputted text is plaintext
<12> result = self.lc.checkLanguage(self.text)
<13> if result:
<14> print("You inputted plain text!")
<15> return {
<16> "lc": self.lc,
<17> "IsPlaintext?": True,
<18> "Plaintext": self.text,
<19> "Cipher": None,
<20> "Extra Information": None,
<21> }
<22> self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
<23> self.what_to_choose: dict = {
<24> self.hash: {
<25> "sha1": self.probability_distribution[0],
<26> "md5": self.probability_distribution[1],
<27> "sha256": self.probability_distribution[2],
<28> "sha512": self.probability_distribution[3],
<29> },
<30> self.basic: {"caesar": self.probability_distribution[4]},
<31> "plaintext": {"plaintext": self.probability_distribution[5]},
<32> self.encoding: {
<33> "reverse": self.probability_distribution[6],
<34> "base64": self.probability_distribution[7],
<35> "binary": self.probability_distribution[8],
<36> "hexadecimal": self.probability_distribution[9],
<37> "ascii": self.probability_distribution[10],
<38> "morse": self.probability_distribution[11],
<39> },
<40> }
<41>
<42> logger.trace(
<43> f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
<44> )
<45>
<46> # sorts each individual sub-dictionary
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
# this should turn off hashing functions if offline mode is turned on
if self.config["offline"]:
if key.__name__() == "hashParent":
continue
self.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.config["grep"]:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
===========unchanged ref 0===========
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
one_level_of_decryption() -> Optional[dict]
at: ciphey.__main__.Ciphey.__init__
self.ai = NeuralNetwork()
self.lc = config["checker"](config)
self.mh = mh.mathsHelper()
self.text: str = config["ctext"]
self.basic = BasicParent(self.lc)
self.hash = HashParent(self.lc)
self.encoding = EncodingParent(self.lc)
self.level: int = 1
self.config = config
self.probability_distribution: dict = {}
self.what_to_choose: dict = {}
at: ciphey.mathsHelper.mathsHelper
sort_prob_table(prob_table: dict) -> dict
at: neuralNetworkMod.nn.NeuralNetwork
predictnn(text)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def base58_bitcoin(self, text: str):
+ logger.trace("Attempting Base58 Bitcoin")
+ return self._dispatch(base58.b58decode, text, "base58_bitcoin")
+
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_bitcoin(self, text: str):
- logger.trace("Attempting Base58 Bitcoin")
- return self._dispatch(base58.b58decode, text, "base58_bitcoin")
-
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def base58_ripple(self, text: str, alphabet: str):
+ logger.trace("Attempting Base58 ripple alphabet")
+ return self._dispatch(base58.b58decode, text, "base58_ripple", alphabet=alphabet)
+
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_ripple(self, text: str):
- logger.trace("Attempting Base58 ripple alphabet")
- return self._dispatch(
- base58.b58decode(alphabet=base58.RIPPLE_ALPHABET), text, "base58_bitcoin"
- )
-
===========changed ref 4===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
self.ascii85(text),
+ self.base58_bitcoin(text),
- self.base85_bitcoin(text),
+ self.base58_ripple(text, alphabet=base58.RIPPLE_ALPHABET),
self.b62(text),
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
===========changed ref 5===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def _dispatch(
+ self, decoder: Callable[[str], bytes], text: str, cipher: str, alphabet=None
- def _dispatch(self, decoder: Callable[[str], bytes], text: str, cipher: str):
+ ):
logger.trace("Attempting base64")
result = None
try:
+ result = decoder(text) if not alphabet else decoder(text, alphabet)
- result = decoder(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
logger.trace("Bad unicode")
result = None
except binascii.Error as e:
logger.trace("binascii error")
result = None
except ValueError:
logger.trace("Failed to decode base")
result = None
except:
logger.trace("Failed to decode base")
result = None
if result is not None and self.lc.checkLanguage(result):
logger.debug(f"Bases successful, returning {result}")
return self.goodRet(result, cipher=cipher)
else:
return self.badRet()
|
|
tests.generate_tests/test_generator.make_test_lc_true_template
|
Modified
|
Ciphey~Ciphey
|
4885f64c2a838cde6a5f579534f4c581098d32b1
|
Honestly this might work but im not too sure
|
<4>:<add> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}''')
<del> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
<6>:<add> result = main(cfg)
<del> result = main(cfg, config={{'offline': True}})
|
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
<0> id = self.randomString(8)
<1> return f"""
<2> def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
<3> # {cipher}
<4> cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
<5> cfg["debug"] = "TRACE"
<6> result = main(cfg, config={{'offline': True}})
<7>
<8> assert result["IsPlaintext?"] == True
<9> """
<10>
|
===========unchanged ref 0===========
at: tests.generate_tests.test_generator
randomString(stringLength)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def base58_bitcoin(self, text: str):
+ logger.trace("Attempting Base58 Bitcoin")
+ return self._dispatch(base58.b58decode, text, "base58_bitcoin")
+
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_bitcoin(self, text: str):
- logger.trace("Attempting Base58 Bitcoin")
- return self._dispatch(base58.b58decode, text, "base58_bitcoin")
-
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def base58_ripple(self, text: str, alphabet: str):
+ logger.trace("Attempting Base58 ripple alphabet")
+ return self._dispatch(base58.b58decode, text, "base58_ripple", alphabet=alphabet)
+
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_ripple(self, text: str):
- logger.trace("Attempting Base58 ripple alphabet")
- return self._dispatch(
- base58.b58decode(alphabet=base58.RIPPLE_ALPHABET), text, "base58_bitcoin"
- )
-
===========changed ref 4===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
self.ascii85(text),
+ self.base58_bitcoin(text),
- self.base85_bitcoin(text),
+ self.base58_ripple(text, alphabet=base58.RIPPLE_ALPHABET),
self.b62(text),
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
===========changed ref 5===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def _dispatch(
+ self, decoder: Callable[[str], bytes], text: str, cipher: str, alphabet=None
- def _dispatch(self, decoder: Callable[[str], bytes], text: str, cipher: str):
+ ):
logger.trace("Attempting base64")
result = None
try:
+ result = decoder(text) if not alphabet else decoder(text, alphabet)
- result = decoder(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
logger.trace("Bad unicode")
result = None
except binascii.Error as e:
logger.trace("binascii error")
result = None
except ValueError:
logger.trace("Failed to decode base")
result = None
except:
logger.trace("Failed to decode base")
result = None
if result is not None and self.lc.checkLanguage(result):
logger.debug(f"Bases successful, returning {result}")
return self.goodRet(result, cipher=cipher)
else:
return self.badRet()
===========changed ref 6===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
"""Performs the decryption of text
Creates the probability table, calls one_level_of_decryption
Args:
None, it uses class variables.
Returns:
None
"""
# Read the documentation for more on this function.
# checks to see if inputted text is plaintext
result = self.lc.checkLanguage(self.text)
if result:
print("You inputted plain text!")
return {
"lc": self.lc,
"IsPlaintext?": True,
"Plaintext": self.text,
"Cipher": None,
"Extra Information": None,
}
self.probability_distribution: dict = self.ai.predictnn(self.text)[0]
self.what_to_choose: dict = {
self.hash: {
"sha1": self.probability_distribution[0],
"md5": self.probability_distribution[1],
"sha256": self.probability_distribution[2],
"sha512": self.probability_distribution[3],
},
self.basic: {"caesar": self.probability_distribution[4]},
"plaintext": {"plaintext": self.probability_distribution[5]},
self.encoding: {
"reverse": self.probability_distribution[6],
"base64": self.probability_distribution[7],
"binary": self.probability_distribution[8],
"hexadecimal": self.probability_distribution[9],
"ascii": self.probability_distribution[10],
"morse": self.probability_distribution[11],
},
}
logger.trace(
f"The probability table before 0.1 in __main__ is {self.what_to_choose}"
)
# sorts each individual sub-dictionary
for key, value in self.what_to_choose.items():
for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all</s>
===========changed ref 7===========
# module: ciphey.__main__
class Ciphey:
def decrypt(self) -> Optional[Dict]:
# offset: 1
<s> for k, v in value.items():
# Sets all 0 probabilities to 0.01, we want Ciphey to try all decryptions.
if v < 0.01:
# this should turn off hashing functions if offline mode is turned on
- if self.config["offline"]:
- if key.__name__() == "hashParent":
- continue
self.what_to_choose[key][k] = 0.01
logger.trace(
f"The probability table after 0.1 in __main__ is {self.what_to_choose}"
)
self.what_to_choose: dict = self.mh.sort_prob_table(self.what_to_choose)
# Creates and prints the probability table
if not self.config["grep"]:
self.produceprobtable(self.what_to_choose)
logger.debug(
f"The new probability table after sorting in __main__ is {self.what_to_choose}"
)
"""
#for each dictionary in the dictionary
# sort that dictionary
#sort the overall dictionary by the first value of the new dictionary
"""
output = None
if self.level <= 1:
output = self.one_level_of_decryption()
else:
# TODO: make tmpfile
f = open("decryptionContents.txt", "w")
output = self.one_level_of_decryption(file=f)
for i in range(0, self.level):
# open file and go through each text item
pass
logger.debug(f"decrypt is outputting {output}")
return output
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
4885f64c2a838cde6a5f579534f4c581098d32b1
|
Honestly this might work but im not too sure
|
<0>:<add> return {
<add> "lc": None,
<add> "IsPlaintext?": False,
<add> "Plaintext": None,
<add> "Cipher": None,
<add> "Extra Information": "The hash wasn't found. Please try Hashkiller.co.uk first, then use Hashcat to manually crack the hash.",
<add> }
<add>
<add>
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
<0> logger.debug(f"Starting to crack hashes")
<1> result = False
<2> if len(hashvalue) == 32:
<3> for api in md5:
<4> r = api(hashvalue, "md5")
<5> result = lc.checkLanguage(r) if r is not None else None
<6> if result is not None or r is not None:
<7> logger.debug(f"MD5 returns True {r}")
<8> return {
<9> "lc": None,
<10> "IsPlaintext?": True,
<11> "Plaintext": r,
<12> "Cipher": "md5",
<13> "Extra Information": None,
<14> }
<15> elif len(hashvalue) == 40:
<16> for api in sha1:
<17> r = api(hashvalue, "sha1")
<18> result = lc.checkLanguage(r) if r is not None else None
<19> if result is not None and r is not None:
<20> logger.debug(f"sha1 returns true")
<21> return {
<22> "lc": None,
<23> "IsPlaintext?": True,
<24> "Plaintext": r,
<25> "Cipher": "sha1",
<26> "Extra Information": None,
<27> }
<28> elif len(hashvalue) == 64:
<29> for api in sha256:
<30> r = api(hashvalue, "sha256")
<31> result = lc.checkLanguage(r) if r is not None else None
<32> if result is not None and r is not None:
<33> logger.debug(f"sha256 returns true")
<34> return {
<35> "lc": None,
<36> "IsPlaintext?": True,
<37> "Plaintext": r,
<38> "Cipher": "sha256",
<39> "Extra Information": None,
<40> }
<41> </s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
# offset: 1
for api in sha384:
r = api(hashvalue, "sha384")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha384 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha512 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha512",
"Extra Information": None,
}
logger.debug(f"Returning None packet")
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.Encoding.bases
class Bases:
+ def base58_bitcoin(self, text: str):
+ logger.trace("Attempting Base58 Bitcoin")
+ return self._dispatch(base58.b58decode, text, "base58_bitcoin")
+
===========changed ref 1===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_bitcoin(self, text: str):
- logger.trace("Attempting Base58 Bitcoin")
- return self._dispatch(base58.b58decode, text, "base58_bitcoin")
-
===========changed ref 2===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def base58_ripple(self, text: str, alphabet: str):
+ logger.trace("Attempting Base58 ripple alphabet")
+ return self._dispatch(base58.b58decode, text, "base58_ripple", alphabet=alphabet)
+
===========changed ref 3===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
- def base85_ripple(self, text: str):
- logger.trace("Attempting Base58 ripple alphabet")
- return self._dispatch(
- base58.b58decode(alphabet=base58.RIPPLE_ALPHABET), text, "base58_bitcoin"
- )
-
===========changed ref 4===========
# module: tests.generate_tests
class test_generator:
def make_test_lc_true_template(self, cipher):
id = self.randomString(8)
return f"""
def test_{cipher['Encrypted Texts']['CipherUsed']}_{id}():
# {cipher}
+ cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}''')
- cfg = make_default_config('''{cipher['Encrypted Texts']['EncryptedText']}'''
cfg["debug"] = "TRACE"
+ result = main(cfg)
- result = main(cfg, config={{'offline': True}})
assert result["IsPlaintext?"] == True
"""
===========changed ref 5===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
def decrypt(self, text: str):
logger.debug("Attempting base decoding")
bases = [
self.base32(text),
self.base16(text),
self.base64(text),
self.base85(text),
self.ascii85(text),
+ self.base58_bitcoin(text),
- self.base85_bitcoin(text),
+ self.base58_ripple(text, alphabet=base58.RIPPLE_ALPHABET),
self.b62(text),
]
for answer in bases:
try:
if answer["IsPlaintext?"]:
# good answer
logger.debug(f"Returning true for {answer}")
return answer
except TypeError:
continue
# Base85
# if nothing works, it has failed.
return self.badRet()
===========changed ref 6===========
# module: ciphey.Decryptor.Encoding.bases
class Bases:
+ def _dispatch(
+ self, decoder: Callable[[str], bytes], text: str, cipher: str, alphabet=None
- def _dispatch(self, decoder: Callable[[str], bytes], text: str, cipher: str):
+ ):
logger.trace("Attempting base64")
result = None
try:
+ result = decoder(text) if not alphabet else decoder(text, alphabet)
- result = decoder(text)
# yeet turning b strings into normal stringy bois
result = result.decode("utf-8")
except UnicodeDecodeError as e:
logger.trace("Bad unicode")
result = None
except binascii.Error as e:
logger.trace("binascii error")
result = None
except ValueError:
logger.trace("Failed to decode base")
result = None
except:
logger.trace("Failed to decode base")
result = None
if result is not None and self.lc.checkLanguage(result):
logger.debug(f"Bases successful, returning {result}")
return self.goodRet(result, cipher=cipher)
else:
return self.badRet()
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
d920ea14bbf987f7213a47622eb4df7fe082739f
|
MERGE ME NOW
|
<0>:<del> return {
<1>:<del> "lc": None,
<2>:<del> "IsPlaintext?": False,
<3>:<del> "Plaintext": None,
<4>:<del> "Cipher": None,
<5>:<del> "Extra Information": "The hash wasn't found. Please try Hashkiller.co.uk first, then use Hashcat to manually crack the hash.",
<6>:<del> }
<7>:<del>
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
<0> return {
<1> "lc": None,
<2> "IsPlaintext?": False,
<3> "Plaintext": None,
<4> "Cipher": None,
<5> "Extra Information": "The hash wasn't found. Please try Hashkiller.co.uk first, then use Hashcat to manually crack the hash.",
<6> }
<7>
<8>
<9> logger.debug(f"Starting to crack hashes")
<10> result = False
<11> if len(hashvalue) == 32:
<12> for api in md5:
<13> r = api(hashvalue, "md5")
<14> result = lc.checkLanguage(r) if r is not None else None
<15> if result is not None or r is not None:
<16> logger.debug(f"MD5 returns True {r}")
<17> return {
<18> "lc": None,
<19> "IsPlaintext?": True,
<20> "Plaintext": r,
<21> "Cipher": "md5",
<22> "Extra Information": None,
<23> }
<24> elif len(hashvalue) == 40:
<25> for api in sha1:
<26> r = api(hashvalue, "sha1")
<27> result = lc.checkLanguage(r) if r is not None else None
<28> if result is not None and r is not None:
<29> logger.debug(f"sha1 returns true")
<30> return {
<31> "lc": None,
<32> "IsPlaintext?": True,
<33> "Plaintext": r,
<34> "Cipher": "sha1",
<35> "Extra Information": None,
<36> }
<37> elif len(hashvalue) == 64:
<38> for api in sha256:
<39> r = api(hashvalue, "sha256")
<40> result = lc.checkLanguage(r) if r is not None else None
</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
# offset: 1
logger.debug(f"sha256 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha256",
"Extra Information": None,
}
elif len(hashvalue) == 96:
for api in sha384:
r = api(hashvalue, "sha384")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha384 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha512 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha512",
"Extra Information": None,
}
logger.debug(f"Returning None packet")
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]
|
ciphey.Decryptor.Encoding.encodingParent/EncodingParent.__init__
|
Modified
|
Ciphey~Ciphey
|
87b77f6e46bf99b995d9aba509bd0c2bde8f7648
|
Add in octal
|
<6>:<add> self.octal = Octal(self.lc)
|
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.base64 = Bases(self.lc)
<2> self.binary = Binary(self.lc)
<3> self.hex = Hexadecimal(self.lc)
<4> self.ascii = Ascii(self.lc)
<5> self.morse = MorseCode(self.lc)
<6>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.ascii
Ascii(lc)
at: ciphey.Decryptor.Encoding.bases
Bases(lc)
at: ciphey.Decryptor.Encoding.binary
Binary(lc)
at: ciphey.Decryptor.Encoding.hexadecimal
Hexadecimal(lc)
===========changed ref 0===========
+ # module: ciphey.Decryptor.Encoding.octal
+
+
===========changed ref 1===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 2===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def decode(self, text):
+ '''
+ It takes an octal string and return a string
+ :octal_str: octal str like "110 145 154"
+ '''
+ str_converted = ""
+ for octal_char in octal_str.split(" "):
+ str_converted += chr(int(octal_char, 8))
+ return str_converted
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def decrypt(self, text):
+ logger.debug("Attempting to decrypt octal")
+ 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 octal")
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": True,
+ "Plaintext": result,
+ "Cipher": "Ascii to Octal encoded",
+ "Extra Information": None,
+ }
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": False,
+ "Plaintext": None,
+ "Cipher": None,
+ "Extra Information": None,
+ }
+
|
ciphey.Decryptor.Encoding.encodingParent/EncodingParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
87b77f6e46bf99b995d9aba509bd0c2bde8f7648
|
Add in octal
|
<1>:<add> torun = [self.base64, self.binary, self.hex, self.ascii, self.morse, self.octal]
<del> torun = [self.base64, self.binary, self.hex, self.ascii, self.morse]
|
# 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> logger.debug(f"Encoding parent is running {torun}")
<3> """
<4> ok so I have an array of functions
<5> and I want to apply each function to some text
<6> (text, function)
<7> but the way it works is you apply text to every item in the array (function)
<8>
<9> """
<10> # from multiprocessing.dummy import Pool as ThreadPool
<11>
<12> # pool = ThreadPool(4)
<13> # answers = pool.map(self.callDecrypt, torun) # It's not worth the thread overhead
<14> answers = map(self.callDecrypt, torun)
<15>
<16> for answer in answers:
<17> logger.debug(f"All answers are {answers}")
<18> # adds the LC objects together
<19> # self.lc = self.lc + answer["lc"]
<20> if answer is not None and answer["IsPlaintext?"]:
<21> logger.debug(f"Plaintext found {answer}")
<22> return answer
<23> return {
<24> "lc": self.lc,
<25> "IsPlaintext?": False,
<26> "Plaintext": None,
<27> "Cipher": None,
<28> "Extra Information": None,
<29> }
<30>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent
callDecrypt(obj)
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent.__init__
self.lc = lc
self.base64 = Bases(self.lc)
self.binary = Binary(self.lc)
self.hex = Hexadecimal(self.lc)
self.ascii = Ascii(self.lc)
self.morse = MorseCode(self.lc)
self.octal = Octal(self.lc)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
def __init__(self, lc):
self.lc = lc
self.base64 = Bases(self.lc)
self.binary = Binary(self.lc)
self.hex = Hexadecimal(self.lc)
self.ascii = Ascii(self.lc)
self.morse = MorseCode(self.lc)
+ self.octal = Octal(self.lc)
===========changed ref 1===========
+ # module: ciphey.Decryptor.Encoding.octal
+
+
===========changed ref 2===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def __init__(self, lc):
+ self.lc = lc
+
===========changed ref 3===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def decode(self, text):
+ '''
+ It takes an octal string and return a string
+ :octal_str: octal str like "110 145 154"
+ '''
+ str_converted = ""
+ for octal_char in octal_str.split(" "):
+ str_converted += chr(int(octal_char, 8))
+ return str_converted
+
===========changed ref 4===========
+ # module: ciphey.Decryptor.Encoding.octal
+ class Octal:
+ def decrypt(self, text):
+ logger.debug("Attempting to decrypt octal")
+ 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 octal")
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": True,
+ "Plaintext": result,
+ "Cipher": "Ascii to Octal encoded",
+ "Extra Information": None,
+ }
+ return {
+ "lc": self.lc,
+ "IsPlaintext?": False,
+ "Plaintext": None,
+ "Cipher": None,
+ "Extra Information": None,
+ }
+
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
b554d775abcbeb85a16f641dd7701dec54d218a4
|
Started adding click
|
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7> parser = argparse.ArgumentParser(
<8> description="""Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it.\n
<9> Examples:
<10> python3 ciphey -t "aGVsbG8gbXkgYmFieQ==" -d true -c true
<11> """
<12> )
<13> parser.add_argument(
<14> "-g",
<15> "--greppable",
<16> help="Only output the answer, no progress bars or information. Useful for grep",
<17> action="store_true",
<18> required=False,
<19> default=False,
<20> )
<21> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<22> parser.add_argument(
<23> "-i",
<24> "--info",
<25> help="Do you want information on the cipher used?",
<26> action="store_true",
<27> required=False,
<28> default=False,
<29> )
<30> parser.add_argument(
<31> "-d",
<32> "--debug",
<33> help="Activates debug mode", # Actually "INFO" level is used, but ¯\_(ツ)_/¯
<34> required=False,
<35> action="store_true",
<36> )
<37> parser.add_argument(
<38> "-D",
<39> "--trace",
<40> help="More verbose than debug mode. Shadows --debug",
<41> required=False,
<42> action="store_true",
<43> )
<44> parser.add_argument(
<45> "-q", "--quiet", help="Supress warnings", required=False, action="store_true",
<46> )
<47> parser.add_argument(
<48> "-a",
<49> "--checker",
<50> help="Uses the given internal language checker. Defaults to brandon",
</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 1
)
parser.add_argument(
"-A",
"--checker-file",
help="Uses the language checker at the given path",
required=False,
)
parser.add_argument(
"-w", "--wordlist", help="Uses the given internal wordlist", required=False,
)
parser.add_argument(
"-W",
"--wordlist-file",
help="Uses the wordlist at the given path",
required=False,
)
parser.add_argument(
"-p",
"--param",
help="Passes a parameter to the language checker",
action="append",
required=False,
default=[],
)
parser.add_argument(
"-l",
"--list-params",
help="Lists the parameters of the selected module",
action="store_true",
required=False,
)
parser.add_argument(
"-O",
"--offline",
help="Run Ciphey in offline mode (No hash support)",
action="store_true",
required=False,
)
parser.add_argument("rest", nargs=argparse.REMAINDER)
args = vars(parser.parse_args())
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
elif len(sys.argv) > 1:
text = args["rest"][0]
elif not sys.stdin.isatty():
text = str(sys.stdin.read())
else:
print("No text input given!")
return None
if len(sys.argv)</s>
===========below chunk 1===========
# module: ciphey.__main__
def arg_parsing() -> Optional[dict]:
# offset: 2
<s>read())
else:
print("No text input given!")
return None
if len(sys.argv) == 1:
print("No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
config["offline"] = args["offline"]
# Try to work out how verbose we should be
if args["trace"]:
config["debug"] = "TRACE"
elif args["debug"]:
config["debug"] = "DEBUG"
elif args["quiet"]:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: argparse
SUPPRESS = '==SUPPRESS=='
REMAINDER = '...'
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: sys
argv: List[str]
stdin: TextIO
at: typing.IO
__slots__ = ()
isatty() -> bool
read(n: int=...) -> AnyStr
at: typing.MutableMapping
pop(key: _KT, default: Union[_VT, _T]=...) -> Union[_VT, _T]
pop(key: _KT) -> _VT
|
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
ea3b39bb88949bbc7f59c7495e732872e35002ab
|
More click stuff
|
<7>:<del> parser = argparse.ArgumentParser(
<8>:<del> description="""Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it.\n
<9>:<del> Examples:
<10>:<del> python3 ciphey -t "aGVsbG8gbXkgYmFieQ==" -d true -c true
<11>:<del> """
<12>:<del> )
<13>:<del> parser.add_argument(
<14>:<del> "-g",
<15>:<del> "--greppable",
<16>:<del> help="Only output the answer, no progress bars or information. Useful for grep",
<17>:<del> action="store_true",
<18>:<del> required=False,
<19>:<del> default=False,
<20>:<del> )
<21>:<del> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<22>:<del> parser.add_argument(
<23>:<del> "-i",
<24>:<del> "--info",
<25>:<del> help="Do you want information on the cipher used?",
<26>:<del> action="store_true",
<27>:<del> required=False,
<28>:<del> default=False,
<29>:<del> )
<30>:<del> parser.add_argument(
<31>:<del> "-d",
<32>:<del> "--debug",
<33>:<del> help="Activates debug mode", # Actually "INFO" level is used, but ¯\_(ツ)_/¯
<34>:<del> required=False,
<35>:<del> action="store_true",
<36>:<del> )
<37>:<del> parser.add_argument(
<38>:<del> "-D",
<39>:<del> "--trace",
<40>:<del> help="More
|
<s> <add> @click.option(
+ "-l", "--list-params", help="List the parameters of the selected module", type=str,
+ )
+ @click.option(
+ "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
+ )
+ def arg_parsing(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7> parser = argparse.ArgumentParser(
<8> description="""Automated decryption tool. Put in the encrypted text and Ciphey will decrypt it.\n
<9> Examples:
<10> python3 ciphey -t "aGVsbG8gbXkgYmFieQ==" -d true -c true
<11> """
<12> )
<13> parser.add_argument(
<14> "-g",
<15> "--greppable",
<16> help="Only output the answer, no progress bars or information. Useful for grep",
<17> action="store_true",
<18> required=False,
<19> default=False,
<20> )
<21> parser.add_argument("-t", "--text", help="Text to decrypt", required=False)
<22> parser.add_argument(
<23> "-i",
<24> "--info",
<25> help="Do you want information on the cipher used?",
<26> action="store_true",
<27> required=False,
<28> default=False,
<29> )
<30> parser.add_argument(
<31> "-d",
<32> "--debug",
<33> help="Activates debug mode", # Actually "INFO" level is used, but ¯\_(ツ)_/¯
<34> required=False,
<35> action="store_true",
<36> )
<37> parser.add_argument(
<38> "-D",
<39> "--trace",
<40> help="More</s>
|
===========below chunk 0===========
<s>(
+ "-l", "--list-params", help="List the parameters of the selected module", type=str,
+ )
+ @click.option(
+ "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
+ )
+ def arg_parsing(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 1
required=False,
action="store_true",
)
parser.add_argument(
"-q", "--quiet", help="Supress warnings", required=False, action="store_true",
)
parser.add_argument(
"-a",
"--checker",
help="Uses the given internal language checker. Defaults to brandon",
required=False,
)
parser.add_argument(
"-A",
"--checker-file",
help="Uses the language checker at the given path",
required=False,
)
parser.add_argument(
"-w", "--wordlist", help="Uses the given internal wordlist", required=False,
)
parser.add_argument(
"-W",
"--wordlist-file",
help="Uses the wordlist at the given path",
required=False,
)
parser.add_argument(
"-p",
"--param",
help="Passes a parameter to the language checker",
action="append",
required=False,
default=[],
)
parser.add_argument(
"-l",
"--list-params",
help="Lists the parameters of the selected module",
action="store_true",
required=False,
)
parser.add_argument(
"-O",
"--offline",
help="Run Ciphey in offline mode (No hash support)",
action="store_true",
required=False,
)
parser.add_argument(
"-dummy",
"--dummy</s>
===========below chunk 1===========
<s>(
+ "-l", "--list-params", help="List the parameters of the selected module", type=str,
+ )
+ @click.option(
+ "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
+ )
+ def arg_parsing(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 2
<s>_true",
required=False,
)
parser.add_argument(
"-dummy",
"--dummy",
help=argparse.SUPPRESS,
default=True,
required=False,
action="store_true",
)
parser.add_argument("rest", nargs=argparse.REMAINDER)
args = vars(parser.parse_args())
print(len(args))
print(args)
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
elif len(sys.argv) > 1:
text = args["rest"][0]
elif not sys.stdin.isatty():
text = str(sys.stdin.read())
print(f"reading from stdin {text}")
else:
text = str(sys.stdin.read())
print(f"Reading from stdin text is {text}")
if not len(text) != 0 and text != "":
print("No text input given!")
return None
if len(sys.argv) == 1:
</s>
===========below chunk 2===========
<s>(
+ "-l", "--list-params", help="List the parameters of the selected module", type=str,
+ )
+ @click.option(
+ "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
+ )
+ def arg_parsing(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 3
<s>No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
config["offline"] = args["offline"]
# Try to work out how verbose we should be
if args["trace"]:
config["debug"] = "TRACE"
elif args["debug"]:
config["debug"] = "DEBUG"
elif args["quiet"]:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("en</s>
===========below chunk 3===========
<s>(
+ "-l", "--list-params", help="List the parameters of the selected module", type=str,
+ )
+ @click.option(
+ "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
+ )
+ def arg_parsing(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 4
<s>))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: ciphey.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: ciphey.__main__
Ciphey(config)
get_name(ctx, param, value)
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
decrypt() -> Optional[Dict]
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
|
ciphey.__main__/get_name
|
Modified
|
Ciphey~Ciphey
|
c235917ecc2da0b10041a11f9f31c498a04b84a2
|
Switching branches
|
<2>:<add> print()click.get_text_stream("stdin").read().strip()
|
# module: ciphey.__main__
def get_name(ctx, param, value):
<0> # reads from stdin if the argument wasnt supplied
<1> if not value and not click.get_text_stream("stdin").isatty():
<2> return click.get_text_stream("stdin").read().strip()
<3> else:
<4> return value
<5>
|
===========unchanged ref 0===========
at: click.utils
get_text_stream(name: str, encoding: Optional[str]=..., errors: str=...) -> IO[str]
at: typing.IO
__slots__ = ()
isatty() -> bool
read(n: int=...) -> AnyStr
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
c716862202971aff88bf84a61a91969068678740
|
Switching branches
|
<7>:<add>
<add> @click.command()
<add> @click.option(
<add> "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
<add> )
<add> @click.option(
<add> "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
<add> )
<add> @click.option("-v", "--verbose", count=True, type=int)
<add> @click.option(
<add> "-a",
<add> "--checker",
<add> help="Use the default internal checker. Defaults to brandon",
<add> type=bool,
<add> )
<add> @click.option(
<add> "-A",
<add> "--checker-path",
<add> help="Uses the language checker at the given path",
<add> type=click.Path(exists=True),
<add> )
<add> @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
<add> @click.option(
<add> "-W",
<add> "--wordlist
|
<s>)
- @click.option(
- "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
- )
- def arg_parsing(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- ) -> Optional[dict]:
+ def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7>
<8> # the below text does:
<9> # if -t is supplied, use that
<10> # if ciphey is called like:
<11> # ciphey 'encrypted text' use that
<12> # else if data is piped like:
<13> # echo 'hello' | ciphey use that
<14> # if no data is supplied, no arguments supplied.
<15>
<16> text = None
<17> if args["text"] is not None:
<18> text = args["text"]
<19> elif len(sys.argv) > 1:
<20> text = args["rest"][0]
<21> elif not sys.stdin.isatty():
<22> text = str(sys.stdin.read())
<23> print(f"reading from stdin {text}")
<24> else:
<25> text = str(sys.stdin.read())
<26> print(f"Reading from stdin text is {text}")
<27> if not len(text) != 0 and text != "":
<28> print("No text input given!")
<29> return None
<30>
<31> if len(sys.argv) == 1:
<32> print("No arguments were supplied. Look at the help menu with -h or --help")
<33> return None
<34>
<35> args["text"] = text
<36> if not args["rest"]:
<37> args.pop("rest")
<38> if len(args["text"]) < 3:
<39> print("A string</s>
|
===========below chunk 0===========
<s>.option(
- "-O", "--offline", help="Run Ciphey in offline mode (no hash support)", type=bool,
- )
- def arg_parsing(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- ) -> Optional[dict]:
+ def arg_parsing() -> Optional[dict]:
# offset: 1
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
config["offline"] = args["offline"]
# Try to work out how verbose we should be
if args["verbose"] >= 3:
config["debug"] = "TRACE"
elif verbose == 2:
config["debug"] = "DEBUG"
elif verbose == 1:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: ciphey.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: ciphey.__main__
get_name(ctx, param, value)
main(config: Dict[str, object]=None) -> Optional[dict]
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: sys
argv: List[str]
stdin: TextIO
at: typing.IO
__slots__ = ()
isatty() -> bool
read(n: int=...) -> AnyStr
|
ciphey.__main__/get_name
|
Modified
|
Ciphey~Ciphey
|
12dea789148ed6d44f4392cf343516f2bd37069d
|
Pretty sure this works now
|
<2>:<add> click.get_text_stream("stdin").read().strip()
<del> print()click.get_text_stream("stdin").read().strip()
|
# module: ciphey.__main__
def get_name(ctx, param, value):
<0> # reads from stdin if the argument wasnt supplied
<1> if not value and not click.get_text_stream("stdin").isatty():
<2> print()click.get_text_stream("stdin").read().strip()
<3> return click.get_text_stream("stdin").read().strip()
<4> else:
<5> return value
<6>
|
===========unchanged ref 0===========
at: click.utils
get_text_stream(name: str, encoding: Optional[str]=..., errors: str=...) -> IO[str]
at: typing.IO
__slots__ = ()
isatty() -> bool
read(n: int=...) -> AnyStr
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
12dea789148ed6d44f4392cf343516f2bd37069d
|
Pretty sure this works now
|
<7>:<del>
<8>:<del> @click.command()
<9>:<del> @click.option(
<10>:<del> "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
<11>:<del> )
<12>:<del> @click.option(
<13>:<del> "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
<14>:<del> )
<15>:<del> @click.option("-v", "--verbose", count=True, type=int)
<16>:<del> @click.option(
<17>:<del> "-a",
<18>:<del> "--checker",
<19>:<del> help="Use the default internal checker. Defaults to brandon",
<20>:<del> type=bool,
<21>:<del> )
<22>:<del> @click.option(
<23>:<del> "-A",
<24>:<del> "--checker-path",
<25>:<del> help="Uses the language checker at the given path",
<26>:<del> type=click.Path(exists=True),
<27>:<del> )
<28>:<del> @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
<29>:<del> @click.option(
<30>:<del> "-W",
<31>:<del> "--wordlist-file",
<32>:<del> help="Uses the wordlist at the given path",
<33>:<del> type=click.File("rb"),
<34>:<del> )
<35>:<del> @click.option(
<36>:<del> "-p", "--param", help="Passes a parameter to the language checker", type=str
<37>:<del> )
<38>:<del> @click.option(
<39>:<del> "-l",
<40>:<del> "--list-params",
<41>:<del> help="List the parameters of the selected module",
<42>:<del> type=str,
<43>:<del> )
<44>:<del> @click.option(
<45>:<del> "-O",
<46>:<del> "--offline",
<47>:<del> help="Run Ciphey in offline mode (no hash support)",
<48>:<del> type=bool,
<49>:<del> )
<50>:<del> @click.argument("text_stdin", callback=get_name, required=False
|
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7>
<8> @click.command()
<9> @click.option(
<10> "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
<11> )
<12> @click.option(
<13> "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
<14> )
<15> @click.option("-v", "--verbose", count=True, type=int)
<16> @click.option(
<17> "-a",
<18> "--checker",
<19> help="Use the default internal checker. Defaults to brandon",
<20> type=bool,
<21> )
<22> @click.option(
<23> "-A",
<24> "--checker-path",
<25> help="Uses the language checker at the given path",
<26> type=click.Path(exists=True),
<27> )
<28> @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
<29> @click.option(
<30> "-W",
<31> "--wordlist-file",
<32> help="Uses the wordlist at the given path",
<33> type=click.File("rb"),
<34> )
<35> @click.option(
<36> "-p", "--param", help="Passes a parameter to the language checker", type=str
<37> )
<38> @click.option(
<39> "-l",
<40> "--list-params",
<41> help="List the parameters of the selected module",
<42> type=str,
<43> )
<44> @click.option(
<45> "-O",
<46> "--offline",
<47> help="Run Ciphey in offline mode (no hash support)",
<48> type=bool,
<49> )
<50> @click.argument("text_stdin", callback=get_name, required=False</s>
|
===========below chunk 0===========
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 1
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(
text,
greppable,
verbose,
checker,
checker_path,
wordlist,
wordlist_file,
param,
list_params,
offline,
text_stdin,
file_stdin,
):
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
elif len(sys.argv) > 1:
text = args["rest"][0]
elif not sys.stdin.isatty():
text = str(sys.stdin.read())
print(f"reading from stdin {text}")
else:
text = str(sys.stdin.read())
print(f"Reading from stdin text is {text}")
if not len(text) != 0 and text != "":
print("No text input given!")
return None
if len(sys.argv) == 1:
print("No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
if not args["rest"]:
args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]</s>
===========below chunk 1===========
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 2
<s> them into a canonical form
#
# First, we go over simple args
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
config["info"] = args["info"]
config["offline"] = args["offline"]
# Try to work out how verbose we should be
if args["verbose"] >= 3:
config["debug"] = "TRACE"
elif verbose == 2:
config["debug"] = "DEBUG"
elif verbose == 1:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
config["params"] = {}
for i in args["param"]:
key, value = i.split("=", 1)
config["params"][key] = value
return config
===========unchanged ref 0===========
at: ciphey.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: ciphey.__main__
get_name(ctx, param, value)
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: sys
argv: List[str]
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: ciphey.__main__
def get_name(ctx, param, value):
# reads from stdin if the argument wasnt supplied
if not value and not click.get_text_stream("stdin").isatty():
+ click.get_text_stream("stdin").read().strip()
- print()click.get_text_stream("stdin").read().strip()
return click.get_text_stream("stdin").read().strip()
else:
return value
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
12dea789148ed6d44f4392cf343516f2bd37069d
|
Pretty sure this works now
|
<14>:<add> config = locals()
<add> config = arg_parsing(config)
<del> config = arg_parsing()
|
<s> required=False)
+ def main(
+ text,
+ greppable,
+ verbose,
+ checker,
+ checker_path,
+ wordlist,
+ wordlist_file,
+ param,
+ list_params,
+ offline,
+ text_stdin,
+ file_stdin,
+ config: Dict[str, object] = None,
+ ) -> Optional[dict]:
- def main(config: Dict[str, object] = None) -> Optional[dict]:
<0> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<1>
<2> It gets the arguments in the function definition using locals()
<3> if withArgs is True, that means this is being called with command line args
<4> so go to arg_parsing() to get those args
<5> we then update locals() with the new command line args and remove "withArgs"
<6> This function then calls call_encryption(**result) which passes our dict of args
<7> to the function as its own arguments using dict unpacking.
<8>
<9> Returns:
<10> The output of the decryption.
<11> """
<12> # We must fill in the arguments if they are not provided
<13> if config is None:
<14> config = arg_parsing()
<15> # Check if we errored out
<16> if config is None:
<17> return None
<18>
<19> # Now we have working arguments, we can expand it and pass it to the Ciphey constructor
<20> cipher_obj = Ciphey(config)
<21> return cipher_obj.decrypt()
<22>
|
===========unchanged ref 0===========
at: ciphey.__main__
Ciphey(config)
arg_parsing(args) -> Optional[dict]
main(text, greppable, verbose, checker, checker_path, wordlist, wordlist_file, param, list_params, offline, text_stdin, file_stdin, config: Dict[str, object]=None) -> Optional[dict]
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
decrypt() -> Optional[Dict]
===========changed ref 0===========
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
"""This function parses arguments.
Args:
None
Returns:
The config to be passed around for the rest of time
"""
-
- @click.command()
- @click.option(
- "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
- )
- @click.option(
- "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
- )
- @click.option("-v", "--verbose", count=True, type=int)
- @click.option(
- "-a",
- "--checker",
- help="Use the default internal checker. Defaults to brandon",
- type=bool,
- )
- @click.option(
- "-A",
- "--checker-path",
- help="Uses the language checker at the given path",
- type=click.Path(exists=True),
- )
- @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
- @click.option(
- "-W",
- "--wordlist-file",
- help="Uses the wordlist at the given path",
- type=click.File("rb"),
- )
- @click.option(
- "-p", "--param", help="Passes a parameter to the language checker", type=str
- )
- @click.option(
- "-l",
- "--list-params",
- help="List the parameters of the selected module",
- type=str,
- )
- @click.option(
- "-O",
- "--offline",
- help="Run Ciphey in offline mode (no hash support)",
- type=bool,
- )
- @click.argument("text_stdin", callback=get_name, required=False)
- @click.</s>
===========changed ref 1===========
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 1
<s> )
- @click.argument("text_stdin", callback=get_name, required=False)
- @click.argument("file_stdin", type=click.File("rb"), required=False)
- def main(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- text_stdin,
- file_stdin,
- ):
-
# the below text does:
# if -t is supplied, use that
# if ciphey is called like:
# ciphey 'encrypted text' use that
# else if data is piped like:
# echo 'hello' | ciphey use that
# if no data is supplied, no arguments supplied.
text = None
if args["text"] is not None:
text = args["text"]
- elif len(sys.argv) > 1:
- text = args["rest"][0]
- elif not sys.stdin.isatty():
- text = str(sys.stdin.read())
- print(f"reading from stdin {text}")
else:
- text = str(sys.stdin.read())
- print(f"Reading from stdin text is {text}")
- if not len(text) != 0 and text != "":
+ print("No input given.")
- print("No text input given!")
+ exit(1)
- return None
if len(sys.argv) == 1:
print("No arguments were supplied. Look at the help menu with -h or --help")
return None
args["text"] = text
- </s>
===========changed ref 2===========
# module: ciphey.__main__
+ def arg_parsing(args) -> Optional[dict]:
- def arg_parsing() -> Optional[dict]:
# offset: 2
<s> args["rest"]:
- args.pop("rest")
if len(args["text"]) < 3:
print("A string of less than 3 chars cannot be interpreted by Ciphey.")
return None
config = dict()
# Now we can walk through the arguments, expanding them into a canonical form
#
# First, we go over simple args
+ config["info"] = False
config["ctext"] = args["text"]
config["grep"] = args["greppable"]
- config["info"] = args["info"]
config["offline"] = args["offline"]
- # Try to work out how verbose we should be
if args["verbose"] >= 3:
config["debug"] = "TRACE"
+ elif args["verbose"] == 2:
- elif verbose == 2:
config["debug"] = "DEBUG"
+ elif args["verbose"] == 1:
- elif verbose == 1:
config["debug"] = "ERROR"
else:
config["debug"] = "WARNING"
# Try to locate language checker module
# TODO: actually implement this
from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
- config["params"] = {}
- for i in args["param"]:
- key, value = i.split("=", 1)
- config["params"][key] = value
return config
===========changed ref 3===========
# module: ciphey.__main__
def get_name(ctx, param, value):
# reads from stdin if the argument wasnt supplied
if not value and not click.get_text_stream("stdin").isatty():
+ click.get_text_stream("stdin").read().strip()
- print()click.get_text_stream("stdin").read().strip()
return click.get_text_stream("stdin").read().strip()
else:
return value
|
test/args
|
Modified
|
Ciphey~Ciphey
|
12dea789148ed6d44f4392cf343516f2bd37069d
|
Pretty sure this works now
|
<0>:<del> @click.command()
<1>:<del> @click.option(
<2>:<del> "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
<3>:<del> )
<4>:<del> @click.option(
<5>:<del> "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
<6>:<del> )
<7>:<del> @click.option("-v", "--verbose", count=True, type=int)
<8>:<add> x = click_parse()
<add> print("helalldaosdoaso")
<add> print(x)
<9>:<del> @click.option(
<10>:<del> "-a",
<11>:<del> "--checker",
<12>:<del> help="Use the default internal checker. Defaults to brandon",
<13>:<del> type=bool,
<14>:<del> )
<15>:<del> @click.option(
<16>:<del> "-A",
<17>:<del> "--checker-path",
<18>:<del> help="Uses the language checker at the given path",
<19>:<del> type=click.Path(exists=True),
<20>:<del> )
<21>:<del> @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
<22>:<del> @click.option(
<23>:<del> "-W",
<24>:<del> "--wordlist-file",
<25>:<del> help="Uses the wordlist at the given path",
<26>:<del> type=click.File("rb"),
<27>:<del> )
<28>:<del> @click.option(
<29>:<del> "-p", "--param", help="Passes a parameter to the language checker", type=str
<30>:<del> )
<31>:<del> @click.option(
<32>:<del> "-l",
<33>:<del> "--list-params",
<34>:<del> help="List the parameters of the selected module",
<35>:<del> type=str,
<36>:<del> )
<37>:<del> @click.option(
<38>:<del> "-O",
<39>:<del> "--offline",
<40>:<del> help="Run Ciphey in offline mode (no hash support)",
<41>:<del> type=bool,
<42>:<del> )
<43>:<del> @click.argument("text_stdin", callback=get_name, required=False)
<44>:<del> @click.argument("file_stdin", type=click.File("rb"), required=False)
<45>:<del> def main(
<46>:<del> text,
<47>:<del> greppable,
<48>:<del> verbose,
<49>:<del> checker,
<50>:<del> checker_path,
<51>:<del> wordlist,
<52>:<del>
|
# module: test
def args():
<0> @click.command()
<1> @click.option(
<2> "-t", "--text", help="The ciphertext you want to decrypt.", type=str,
<3> )
<4> @click.option(
<5> "-g", "--greppable", help="Only output the answer. Useful for grep.", type=bool
<6> )
<7> @click.option("-v", "--verbose", count=True, type=int)
<8>
<9> @click.option(
<10> "-a",
<11> "--checker",
<12> help="Use the default internal checker. Defaults to brandon",
<13> type=bool,
<14> )
<15> @click.option(
<16> "-A",
<17> "--checker-path",
<18> help="Uses the language checker at the given path",
<19> type=click.Path(exists=True),
<20> )
<21> @click.option("-w", "--wordlist", help="Uses the given internal wordlist")
<22> @click.option(
<23> "-W",
<24> "--wordlist-file",
<25> help="Uses the wordlist at the given path",
<26> type=click.File("rb"),
<27> )
<28> @click.option(
<29> "-p", "--param", help="Passes a parameter to the language checker", type=str
<30> )
<31> @click.option(
<32> "-l",
<33> "--list-params",
<34> help="List the parameters of the selected module",
<35> type=str,
<36> )
<37> @click.option(
<38> "-O",
<39> "--offline",
<40> help="Run Ciphey in offline mode (no hash support)",
<41> type=bool,
<42> )
<43> @click.argument("text_stdin", callback=get_name, required=False)
<44> @click.argument("file_stdin", type=click.File("rb"), required=False)
<45> def main(
<46> text,
<47> greppable,
<48> verbose,
<49> checker,
<50> checker_path,
<51> wordlist,
<52> </s>
|
===========below chunk 0===========
# module: test
def args():
# offset: 1
param,
list_params,
offline,
text_stdin,
file_stdin,
):
if text is not None:
print(f"Text is {text}")
else:
print(f"std in is {text_stdin}")
print(verbose)
print(file_stdin)
main()
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: test
get_name(ctx, param, value)
===========changed ref 0===========
# module: ciphey.__main__
def get_name(ctx, param, value):
# reads from stdin if the argument wasnt supplied
if not value and not click.get_text_stream("stdin").isatty():
+ click.get_text_stream("stdin").read().strip()
- print()click.get_text_stream("stdin").read().strip()
return click.get_text_stream("stdin").read().strip()
else:
return value
===========changed ref 1===========
<s> required=False)
+ def main(
+ text,
+ greppable,
+ verbose,
+ checker,
+ checker_path,
+ wordlist,
+ wordlist_file,
+ param,
+ list_params,
+ offline,
+ text_stdin,
+ file_stdin,
+ config: Dict[str, object] = None,
+ ) -> Optional[dict]:
- def main(config: Dict[str, object] = None) -> Optional[dict]:
"""Function to deal with arguments. Either calls with args or not. Makes Pytest work.
It gets the arguments in the function definition using locals()
if withArgs is True, that means this is being called with command line args
so go to arg_parsing() to get those args
we then update locals() with the new command line args and remove "withArgs"
This function then calls call_encryption(**result) which passes our dict of args
to the function as its own arguments using dict unpacking.
Returns:
The output of the decryption.
"""
# We must fill in the arguments if they are not provided
if config is None:
+ config = locals()
+ config = arg_parsing(config)
- config = arg_parsing()
# Check if we errored out
if config is None:
return None
# Now we have working arguments, we can expand it and pass it to the Ciphey constructor
cipher_obj = Ciphey(config)
return cipher_obj.decrypt()
|
ciphey.__main__/arg_parsing
|
Modified
|
Ciphey~Ciphey
|
76376bc60d9b2fe73c661ac7ad8e054ccf6cd8c0
|
Re-cloning
|
# module: ciphey.__main__
def arg_parsing(args) -> Optional[dict]:
<0> """This function parses arguments.
<1>
<2> Args:
<3> None
<4> Returns:
<5> The config to be passed around for the rest of time
<6> """
<7> # the below text does:
<8> # if -t is supplied, use that
<9> # if ciphey is called like:
<10> # ciphey 'encrypted text' use that
<11> # else if data is piped like:
<12> # echo 'hello' | ciphey use that
<13> # if no data is supplied, no arguments supplied.
<14>
<15> text = None
<16> if args["text"] is not None:
<17> text = args["text"]
<18> else:
<19> print("No input given.")
<20> exit(1)
<21>
<22> if len(sys.argv) == 1:
<23> print("No arguments were supplied. Look at the help menu with -h or --help")
<24> return None
<25>
<26> args["text"] = text
<27> if len(args["text"]) < 3:
<28> print("A string of less than 3 chars cannot be interpreted by Ciphey.")
<29> return None
<30>
<31> config = dict()
<32>
<33> # Now we can walk through the arguments, expanding them into a canonical form
<34> #
<35> # First, we go over simple args
<36> config["info"] = False
<37> config["ctext"] = args["text"]
<38> config["grep"] = args["greppable"]
<39> config["offline"] = args["offline"]
<40> if args["verbose"] >= 3:
<41> config["debug"] = "TRACE"
<42> elif args["verbose"] == 2:
<43> config["debug"] = "DEBUG"
<44> elif args["verbose"] == 1:
<45> config["debug"] = "ERROR"
<46> else:
<47> config["debug"] = "WARNING"
<48> # Try to locate language checker module
<49> # TODO: actually implement this
<50> from ciphey.LanguageChecker.brandon import ciphey_language_checker as</s>
|
===========below chunk 0===========
# module: ciphey.__main__
def arg_parsing(args) -> Optional[dict]:
# offset: 1
config["checker"] = brandon
# Try to locate language checker module
# TODO: actually implement this (should be similar)
import cipheydists
config["wordlist"] = set(cipheydists.get_list("english"))
# Now we fill in the params *shudder*
return config
===========unchanged ref 0===========
at: ciphey.LanguageChecker.brandon
ciphey_language_checker = Brandon
at: sys
argv: List[str]
|
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
e47ef8d896e19d18780db3a105db5bb8da499ceb
|
File input using - symbol now works
|
<0>:<add> """Ciphey - Automated Decryption Tool
<add>
<add> Documentation:
<add> https://docs.ciphey.online\n
<add> Support:
<add> https://github.com/ciphey/ciphey\n
<add> Discord:\n
<add> https://discord.gg/sfdG5xx
<add>
<add> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<add>
<add> Examples:\n
<add> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<add>
<add> """
<add> """HARLAN or other contribs. The above text is printed upon help menu being called"""
<12>:<add>
<add> if text is None:
<add> if file_stdin is not None:
<add> text = file_stdin.read().decode("utf-8")
<add> elif text_stdin is not None:
<add>
|
<s>.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(
text,
greppable,
verbose,
checker,
checker_path,
wordlist,
wordlist_file,
param,
list_params,
offline,
text_stdin,
file_stdin,
config: Dict[str, object] = None,
) -> Optional[dict]:
<0> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<1>
<2> It gets the arguments in the function definition using locals()
<3> if withArgs is True, that means this is being called with command line args
<4> so go to arg_parsing() to get those args
<5> we then update locals() with the new command line args and remove "withArgs"
<6> This function then calls call_encryption(**result) which passes our dict of args
<7> to the function as its own arguments using dict unpacking.
<8>
<9> Returns:
<10> The output of the decryption.
<11> """
<12> # We must fill in the arguments if they are not provided
<13> if config is None:
<14> config = locals()
<15> config = arg_parsing(config)
<16> # Check if we errored out
<17> if config is None:
<18> return None
<19>
<20> # Now we have working arguments, we can expand it and pass it to the Ciphey constructor
<21> cipher_obj = Ciphey(config)
<22> return cipher_obj.decrypt()
<23>
|
===========unchanged ref 0===========
at: ciphey.__main__
get_name(ctx, param, value)
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
1a3d7671fb084c2b2ef63e7952511cd2f0d528bf
|
fixing PyTest, fully works now other than pytest
|
<0>:<del> """Ciphey - Automated Decryption Tool
<1>:<del>
<2>:<del> Documentation:
<3>:<del> https://docs.ciphey.online\n
<4>:<del> Support:
<5>:<del> https://github.com/ciphey/ciphey\n
<6>:<del> Discord:\n
<7>:<del> https://discord.gg/sfdG5xx
<8>:<del>
<9>:<del> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>:<del>
<11>:<del> Examples:\n
<12>:<del> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<13>:<del>
<14>:<del> """
<15>:<del> """HARLAN or other contribs. The above text is printed upon help menu being called"""
<28>:<del>
<29>:<add> if text is not None:
<del> if text is None:
<30>:<del> if file_stdin is not None:
<31>:<del> text = file_stdin.read().decode("utf-8")
<32>:<del> elif text_
|
<s>def main(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- text_stdin,
- file_stdin,
- config: Dict[str, object] = None,
- ) -> Optional[dict]:
+ def main(config: Dict[str, object] = None, text: str = None) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Support:
<5> https://github.com/ciphey/ciphey\n
<6> Discord:\n
<7> https://discord.gg/sfdG5xx
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<13>
<14> """
<15> """HARLAN or other contribs. The above text is printed upon help menu being called"""
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> if text is None:
<30> if file_stdin is not None:
<31> text = file_stdin.read().decode("utf-8")
<32> elif text_</s>
|
===========below chunk 0===========
<s> text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- text_stdin,
- file_stdin,
- config: Dict[str, object] = None,
- ) -> Optional[dict]:
+ def main(config: Dict[str, object] = None, text: str = None) -> Optional[dict]:
# offset: 1
text = text_stdin
else:
print("No inputs were given to Ciphey. Run ciphey --help")
return None
print(text)
# We must fill in the arguments if they are not provided
if config is None:
config = locals()
config = arg_parsing(config)
# Check if we errored out
if config is None:
return None
# Now we have working arguments, we can expand it and pass it to the Ciphey constructor
cipher_obj = Ciphey(config)
return cipher_obj.decrypt()
===========unchanged ref 0===========
at: ciphey.__main__
Ciphey(config)
get_name(ctx, param, value)
arg_parsing(args) -> Optional[dict]
at: ciphey.__main__.Ciphey
config = dict()
params = dict()
decrypt() -> Optional[Dict]
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
8b5928f2b75add987d2ccdca3395b21ad74506ec
|
Pytest now works
|
<0>:<add> """Ciphey - Automated Decryption Tool
<add>
<add> Documentation:
<add> https://docs.ciphey.online\n
<add> Discord (support here, we're online most of the day):
<add> https://discord.ciphey.online/\n
<add> GitHub:
<add> https://github.com/ciphey/ciphey\n
<add>
<add> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<add>
<add> Examples:\n
<add> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<add>
<add> """
<add>
<12>:<del> if text is not None:
<13>:<del> config["ctext"] = text
<14>:<del> config["text"] = text
<16>:<add> if config is None:
<add> config = locals()
<add> config = arg_parsing(config)
<add> # Check if we errored out
<add> if config is None:
<add> return None
<del> # Now we have working arguments, we can expand it and pass it to the Ciphey constructor
<17>:<del> cipher_obj = Ciphey(config)
<18>:<del> # print(cipher_obj.ctext)
|
<s>def main(
+ text,
+ greppable,
+ verbose,
+ checker,
+ checker_path,
+ wordlist,
+ wordlist_file,
+ param,
+ list_params,
+ offline,
+ text_stdin,
+ file_stdin,
+ config: Dict[str, object] = None,
+ ) -> Optional[dict]:
- def main(config: Dict[str, object] = None, text: str = None) -> Optional[dict]:
<0> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<1>
<2> It gets the arguments in the function definition using locals()
<3> if withArgs is True, that means this is being called with command line args
<4> so go to arg_parsing() to get those args
<5> we then update locals() with the new command line args and remove "withArgs"
<6> This function then calls call_encryption(**result) which passes our dict of args
<7> to the function as its own arguments using dict unpacking.
<8>
<9> Returns:
<10> The output of the decryption.
<11> """
<12> if text is not None:
<13> config["ctext"] = text
<14> config["text"] = text
<15>
<16> # Now we have working arguments, we can expand it and pass it to the Ciphey constructor
<17> cipher_obj = Ciphey(config)
<18> # print(cipher_obj.ctext)
<19> return cipher_obj.decrypt()
<20>
|
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
|
tests.test_main/test_argument_grep_true
|
Modified
|
Ciphey~Ciphey
|
afa102cf02b6830c6de2e15868ea11e2f041e586
|
added tests
|
<2>:<add> result = main_decrypt(cfg)
<del> result = main(cfg)
|
# module: tests.test_main
def test_argument_grep_true():
<0> cfg = make_default_config("It was the best of times, it was the worst of times")
<1> cfg["debug"] = "TRACE"
<2> result = main(cfg)
<3> assert result["Plaintext"] == "It was the best of times, it was the worst of times"
<4>
|
===========unchanged ref 0===========
at: ciphey.__main__
make_default_config(ctext: str, trace: bool=False) -> Dict[str, object]
main_decrypt(config: Dict[str, object]=None) -> Optional[dict]
|
tests.test_main/test_main_base64_true
|
Modified
|
Ciphey~Ciphey
|
afa102cf02b6830c6de2e15868ea11e2f041e586
|
added tests
|
<0>:<add> cfg = make_default_config(
<add> "SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLiBUaGVyZSBpcyBvbmx5IHNvIG11Y2ggcm9hZCBpbiBEb3ZlciBvbmUgY2FuIGxheS4="
<del> cfg = make_default_config("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLiBUaGVyZSBpcyBvbmx5IHNvIG11Y2ggcm9hZCBpbiBEb3ZlciBvbmUgY2FuIGxheS4=")
<1>:<add> )
<2>:<add> result = main_decrypt(cfg)
<del> result = main(cfg)
<4>:<add> result["Plaintext"]
<add> == "It was the best of times, it was the worst of times. There is only so much road in Dover one can lay."
<del> result["Plaintext"] == "It was the best of times, it was the worst of times. There is only so much road in Dover one can lay."
|
# module: tests.test_main
def test_main_base64_true():
<0> cfg = make_default_config("SXQgd2FzIHRoZSBiZXN0IG9mIHRpbWVzLCBpdCB3YXMgdGhlIHdvcnN0IG9mIHRpbWVzLiBUaGVyZSBpcyBvbmx5IHNvIG11Y2ggcm9hZCBpbiBEb3ZlciBvbmUgY2FuIGxheS4=")
<1> cfg["debug"] = "TRACE"
<2> result = main(cfg)
<3> assert (
<4> result["Plaintext"] == "It was the best of times, it was the worst of times. There is only so much road in Dover one can lay."
<5> )
<6>
|
===========unchanged ref 0===========
at: ciphey.__main__
make_default_config(ctext: str, trace: bool=False) -> Dict[str, object]
main_decrypt(config: Dict[str, object]=None) -> Optional[dict]
===========changed ref 0===========
# module: tests.test_main
def test_argument_grep_true():
cfg = make_default_config("It was the best of times, it was the worst of times")
cfg["debug"] = "TRACE"
+ result = main_decrypt(cfg)
- result = main(cfg)
assert result["Plaintext"] == "It was the best of times, it was the worst of times"
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
4528fe53c5ec445fd4935aaa69ee02ee6dd41e2d
|
I forgot to remove a print debug statement
|
<31>:<add>
<add> if config["text"] is None:
<add> if file_stdin is not None:
<add> config["text"] = file_stdin.read().decode("utf-8")
<add> elif text_stdin is not None:
<add> config["text"] = text_stdin
<add> else:
<add> print("No inputs were given to Ciphey. Run ciphey --help")
<add> return None
<add>
<36>:<del> ((bad delete))
|
<s>.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(
text,
greppable,
verbose,
checker,
checker_path,
wordlist,
wordlist_file,
param,
list_params,
offline,
text_stdin,
file_stdin,
config: Dict[str, object] = None,
) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> if config is None:
<30> config = locals()
<31> config = arg_parsing(config)
<32> # Check if we errored out
<33> if config is None:
<34> return None
<35>
<36> </s>
|
===========below chunk 0===========
<s>stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(
text,
greppable,
verbose,
checker,
checker_path,
wordlist,
wordlist_file,
param,
list_params,
offline,
text_stdin,
file_stdin,
config: Dict[str, object] = None,
) -> Optional[dict]:
# offset: 1
if file_stdin is not None:
config["text "] = file_stdin.read().decode("utf-8")
elif text_stdin is not None:
config["text "] = text_stdin
else:
print("No inputs were given to Ciphey. Run ciphey --help")
return None
return main_decrypt(config)
===========unchanged ref 0===========
at: ciphey.__main__
get_name(ctx, param, value)
arg_parsing(args) -> Optional[dict]
main_decrypt(config: Dict[str, object]=None) -> Optional[dict]
at: click.decorators
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<12>:<add> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU=" -d true -c true
<del> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<29>:<del> if config is None:
<30>:<del> config = locals()
<32>:<del> if config["text"] is None:
<33>:<del> if file_stdin is not None:
<34>:<del> config["text"] = file_stdin.read().
|
<s>=click.File("rb"), required=False)
- def main(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- text_stdin,
- file_stdin,
- config: Dict[str, object] = None,
- ) -> Optional[dict]:
+ def main(**kwargs) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU="
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> if config is None:
<30> config = locals()
<31>
<32> if config["text"] is None:
<33> if file_stdin is not None:
<34> config["text"] = file_stdin.read().</s>
|
===========below chunk 0===========
<s>rb"), required=False)
- def main(
- text,
- greppable,
- verbose,
- checker,
- checker_path,
- wordlist,
- wordlist_file,
- param,
- list_params,
- offline,
- text_stdin,
- file_stdin,
- config: Dict[str, object] = None,
- ) -> Optional[dict]:
+ def main(**kwargs) -> Optional[dict]:
# offset: 1
elif text_stdin is not None:
config["text"] = text_stdin
else:
print("No inputs were given to Ciphey. Run ciphey --help")
return None
config = arg_parsing(config)
# Check if we errored out
if config is None:
return None
return main_decrypt(config)
===========unchanged ref 0===========
at: ciphey.__main__
get_name(ctx, param, value)
arg_parsing(args) -> Optional[dict]
main_decrypt(config: Dict[str, object]=None) -> Optional[dict]
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: click.types
File(mode: Text=..., encoding: Optional[str]=..., errors: Optional[str]=..., lazy: Optional[bool]=..., atomic: Optional[bool]=...)
Path(exists: bool=..., file_okay: bool=..., dir_okay: bool=..., writable: bool=..., readable: bool=..., resolve_path: bool=..., allow_dash: bool=..., path_type: Optional[Type[_PathType]]=...)
at: typing
Dict = _alias(dict, 2, inst=False, name='Dict')
===========changed ref 0===========
# module: ciphey.__main__
- def arg_parsing(args) -> Optional[dict]:
- """This function parses arguments.
-
- Args:
- None
- Returns:
- The config to be passed around for the rest of time
- """
- # the below text does:
- # if -t is supplied, use that
- # if ciphey is called like:
- # ciphey 'encrypted text' use that
- # else if data is piped like:
- # echo 'hello' | ciphey use that
- # if no data is supplied, no arguments supplied.
- text = None
- if args["text"] is not None:
- text = args["text"]
- else:
- print("No input given.")
- exit(1)
-
- if len(sys.argv) == 1:
- print("No arguments were supplied. Look at the help menu with -h or --help")
- return None
-
- args["text"] = text
- if len(args["text"]) < 3:
- print("A string of less than 3 chars cannot be interpreted by Ciphey.")
- return None
-
- config = dict()
-
- # Now we can walk through the arguments, expanding them into a canonical form
- #
- # First, we go over simple args
- config["info"] = False
- config["ctext"] = args["text"]
- config["grep"] = args["greppable"]
- config["offline"] = args["offline"]
- if args["verbose"] >= 3:
- config["debug"] = "TRACE"
- elif args["verbose"] == 2:
- config["debug"] = "DEBUG"
- elif args["verbose"] == 1:
- config["debug"] = "ERROR"
- else:
- config["debug"] = "WARNING"
- # Try to locate language checker module
- # TODO: actually implement this
- from ciphey.LanguageChecker.brandon import ciphey_language_checker as brand</s>
===========changed ref 1===========
# module: ciphey.__main__
- def arg_parsing(args) -> Optional[dict]:
# offset: 1
<s> # TODO: actually implement this
- from ciphey.LanguageChecker.brandon import ciphey_language_checker as brandon
-
- config["checker"] = brandon
- # Try to locate language checker module
- # TODO: actually implement this (should be similar)
- import cipheydists
-
- config["wordlist"] = set(cipheydists.get_list("english"))
- # Now we fill in the params *shudder*
- config["params"] = {}
- return config
-
|
ciphey.mathsHelper/mathsHelper.sort_prob_table
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<27>:<add> logger.trace(
<del> logger.debug(
<31>:<add> logger.trace(f"Sorting {key}")
<del> logger.debug(f"Sorting {key}")
<35>:<add> logger.trace(
<del> logger.debug(
<39>:<add> logger.trace(
<del> logger.debug(
|
# module: ciphey.mathsHelper
class mathsHelper:
def sort_prob_table(self, prob_table: dict) -> dict:
<0> """Sorts the probability table.
<1>
<2> Sorts a dictionary of dictionaries (and all the sub-dictionaries).
<3>
<4> Args:
<5> prob_table -> The probability table returned by the neural network to sort.
<6>
<7> Returns:
<8> Returns the prob_table, but sorted.
<9>
<10> """
<11> # for each object: prob table in dictionary
<12> max_overall: int = 0
<13> max_dict_pair: dict = {}
<14> highest_key = None
<15> empty_dict: dict = {}
<16> # sorts the prob table before we find max, and converts it to order dicts
<17> for key, value in prob_table.items():
<18> prob_table[key] = self.new_sort(value)
<19> prob_table[key] = dict(prob_table[key])
<20>
<21> # gets maximum key then sets it to the front
<22> counter_max: int = 0
<23> counter_prob: int = len(prob_table)
<24> while counter_max < counter_prob:
<25> max_overall = 0
<26> highest_key = None
<27> logger.debug(
<28> f"Running while loop in sort_prob_table, counterMax is {counter_max}"
<29> )
<30> for key, value in prob_table.items():
<31> logger.debug(f"Sorting {key}")
<32> maxLocal = 0
<33> # for each item in that table
<34> for key2, value2 in value.items():
<35> logger.debug(
<36> f"Running key2 {key2}, value2 {value2} for loop for {value.items()}"
<37> )
<38> maxLocal = maxLocal + value2
<39> logger.debug(
<40> f"MaxLocal is {maxLocal}</s>
|
===========below chunk 0===========
# module: ciphey.mathsHelper
class mathsHelper:
def sort_prob_table(self, prob_table: dict) -> dict:
# offset: 1
)
if maxLocal > max_overall:
logger.debug(f"New max local found {maxLocal}")
# because the dict doesnt reset
max_dict_pair = {}
max_overall = maxLocal
# so eventually, we get the maximum dict pairing?
max_dict_pair[key] = value
highest_key = key
logger.debug(f"Highest key is {highest_key}")
# removes the highest key from the prob table
logger.debug(f"Prob table is {prob_table} and highest key is {highest_key}")
logger.debug(f"Removing {prob_table[highest_key]}")
del prob_table[highest_key]
logger.debug(f"Prob table after deletion is {prob_table}")
counter_max += 1
empty_dict = {**empty_dict, **max_dict_pair}
# returns the max dict (at the start) with the prob table
# this way, it should always work on most likely first.
logger.debug(
f"The prob table is {prob_table} and the maxDictPair is {max_dict_pair}"
)
logger.debug(f"The new sorted prob table is {empty_dict}")
return empty_dict
===========unchanged ref 0===========
at: ciphey.mathsHelper.mathsHelper
new_sort(new_dict: dict) -> dict
===========changed ref 0===========
+ # module: ciphey.basemods
+
+
===========changed ref 1===========
+ # module: ciphey.iface
+
+
===========changed ref 2===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 3===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 4===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 5===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 6===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 7===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 10===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 12===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 18===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 21===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 22===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 24===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 25===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 26===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 28===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 29===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
|
ciphey.mathsHelper/mathsHelper.new_sort
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<12>:<add> logger.trace(f"The old dictionary before new_sort() is {new_dict}")
<del> logger.debug(f"The old dictionary before new_sort() is {new_dict}")
<16>:<add> logger.trace(f"The dictionary after new_sort() is {sorted_i}")
<del> logger.debug(f"The dictionary after new_sort() is {sorted_i}")
|
# module: ciphey.mathsHelper
class mathsHelper:
@staticmethod
def new_sort(new_dict: dict) -> dict:
<0> """Uses OrderedDict to sort a dictionary.
<1>
<2> I think it's faster than my implementation.
<3>
<4> Args:
<5> new_dict -> the dictionary to sort
<6>
<7> Returns:
<8> Returns the dict, but sorted.
<9>
<10> """
<11> # (f"d is {d}")
<12> logger.debug(f"The old dictionary before new_sort() is {new_dict}")
<13> sorted_i = OrderedDict(
<14> sorted(new_dict.items(), key=lambda x: x[1], reverse=True)
<15> )
<16> logger.debug(f"The dictionary after new_sort() is {sorted_i}")
<17> # sortedI = sort_dictionary(x)
<18> return sorted_i
<19>
|
===========unchanged ref 0===========
at: collections
OrderedDict(map: Mapping[_KT, _VT], **kwargs: _VT)
OrderedDict(**kwargs: _VT)
OrderedDict(iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT)
===========changed ref 0===========
# module: ciphey.mathsHelper
class mathsHelper:
def sort_prob_table(self, prob_table: dict) -> dict:
"""Sorts the probability table.
Sorts a dictionary of dictionaries (and all the sub-dictionaries).
Args:
prob_table -> The probability table returned by the neural network to sort.
Returns:
Returns the prob_table, but sorted.
"""
# for each object: prob table in dictionary
max_overall: int = 0
max_dict_pair: dict = {}
highest_key = None
empty_dict: dict = {}
# sorts the prob table before we find max, and converts it to order dicts
for key, value in prob_table.items():
prob_table[key] = self.new_sort(value)
prob_table[key] = dict(prob_table[key])
# gets maximum key then sets it to the front
counter_max: int = 0
counter_prob: int = len(prob_table)
while counter_max < counter_prob:
max_overall = 0
highest_key = None
+ logger.trace(
- logger.debug(
f"Running while loop in sort_prob_table, counterMax is {counter_max}"
)
for key, value in prob_table.items():
+ logger.trace(f"Sorting {key}")
- logger.debug(f"Sorting {key}")
maxLocal = 0
# for each item in that table
for key2, value2 in value.items():
+ logger.trace(
- logger.debug(
f"Running key2 {key2}, value2 {value2} for loop for {value.items()}"
)
maxLocal = maxLocal + value2
+ logger.trace(
- logger.debug(
f"MaxLocal is {max</s>
===========changed ref 1===========
# module: ciphey.mathsHelper
class mathsHelper:
def sort_prob_table(self, prob_table: dict) -> dict:
# offset: 1
<s>Local + value2
+ logger.trace(
- logger.debug(
f"MaxLocal is {maxLocal} and maxOverall is {max_overall}"
)
if maxLocal > max_overall:
+ logger.trace(f"New max local found {maxLocal}")
- logger.debug(f"New max local found {maxLocal}")
# because the dict doesnt reset
max_dict_pair = {}
max_overall = maxLocal
# so eventually, we get the maximum dict pairing?
max_dict_pair[key] = value
highest_key = key
+ logger.trace(f"Highest key is {highest_key}")
- logger.debug(f"Highest key is {highest_key}")
# removes the highest key from the prob table
+ logger.trace(f"Prob table is {prob_table} and highest key is {highest_key}")
- logger.debug(f"Prob table is {prob_table} and highest key is {highest_key}")
+ logger.trace(f"Removing {prob_table[highest_key]}")
- logger.debug(f"Removing {prob_table[highest_key]}")
del prob_table[highest_key]
+ logger.trace(f"Prob table after deletion is {prob_table}")
- logger.debug(f"Prob table after deletion is {prob_table}")
counter_max += 1
empty_dict = {**empty_dict, **max_dict_pair}
# returns the max dict (at the start) with the prob table
# this way, it should always work on most</s>
===========changed ref 2===========
# module: ciphey.mathsHelper
class mathsHelper:
def sort_prob_table(self, prob_table: dict) -> dict:
# offset: 2
<s>.
+ logger.trace(
- logger.debug(
f"The prob table is {prob_table} and the maxDictPair is {max_dict_pair}"
)
+ logger.trace(f"The new sorted prob table is {empty_dict}")
- logger.debug(f"The new sorted prob table is {empty_dict}")
return empty_dict
===========changed ref 3===========
+ # module: ciphey.basemods
+
+
===========changed ref 4===========
+ # module: ciphey.iface
+
+
===========changed ref 5===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 6===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 7===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 9===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 13===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 15===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
|
tests.integration/testIntegration.test_basics
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check(
<del> result = lc.checkLanguage(
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage(
<2> "Hello my name is new and this is an example of some english text"
<3> )
<4> self.assertEqual(result, True)
<5>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
failureException: Type[BaseException]
longMessage: bool
maxDiff: Optional[int]
_testMethodName: str
_testMethodDoc: str
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
+ # module: ciphey.basemods
+
+
===========changed ref 1===========
+ # module: ciphey.iface
+
+
===========changed ref 2===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 3===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 4===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 5===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 6===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 7===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 10===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 12===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 18===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 21===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 22===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 24===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 25===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 26===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 28===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 29===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __le__(self, other: "DecoderComparer"):
+ return self.value.priority() <= other.value.priority()
+
===========changed ref 32===========
<s>, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @staticmethod
+ @abstractmethod
+ def priority() -> float:
+ """What proportion of decodings are this?"""
+ pass
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ T = TypeVar("T")
+ U = TypeVar("U")
+
===========changed ref 34===========
+ # module: ciphey.iface._modules
+ class Targeted(ABC):
+ @staticmethod
+ @abstractmethod
+ def getTarget() -> str:
+ """Should return the target that this object attacks/decodes"""
+ pass
+
|
tests.integration/testIntegration.test_basics_german
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check("hallo keine lieben leute nach")
<del> result = lc.checkLanguage("hallo keine lieben leute nach")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("hallo keine lieben leute nach")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 1===========
+ # module: ciphey.basemods
+
+
===========changed ref 2===========
+ # module: ciphey.iface
+
+
===========changed ref 3===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 4===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 5===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 6===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 7===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 11===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 13===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 18===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 19===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 21===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 22===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 23===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 24===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 25===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 26===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 27===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 28===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 29===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __le__(self, other: "DecoderComparer"):
+ return self.value.priority() <= other.value.priority()
+
===========changed ref 33===========
<s>, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @staticmethod
+ @abstractmethod
+ def priority() -> float:
+ """What proportion of decodings are this?"""
+ pass
+
===========changed ref 34===========
+ # module: ciphey.iface._modules
+ T = TypeVar("T")
+ U = TypeVar("U")
+
|
tests.integration/testIntegration.test_basics_quickbrownfox
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<3>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<4>:<add> result = lc.check("The quick brown fox jumped over the lazy dog")
<del> result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
<0> """
<1> This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
<2> """
<3> lc = LanguageChecker.LanguageChecker()
<4> result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
<5> self.assertEqual(result, True)
<6>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 2===========
+ # module: ciphey.basemods
+
+
===========changed ref 3===========
+ # module: ciphey.iface
+
+
===========changed ref 4===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 5===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 6===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 7===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 8===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 12===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 14===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 18===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 21===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 22===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 23===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 24===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 25===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 26===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 27===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 28===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 29===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 30===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __le__(self, other: "DecoderComparer"):
+ return self.value.priority() <= other.value.priority()
+
|
tests.integration/testIntegration.test_chi_maxima_true
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<3>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<4>:<add> result = lc.check("sa dew fea dxza dcsa da fsa d")
<del> result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
<5>:<add> result = lc.check("df grtsf a sgrds fgserwqd")
<del> result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
<6>:<add> result = lc.check("fd sa fe safsda srmad sadsa d")
<del> result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
<7>:<add> result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
<del> result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
<8>:<add> result = lc.check(
<del> result = lc.checkLanguage(
<11>:<add> result = lc.check("r jabbi tb y jyg ygiuygytff u0")
<del> result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
<12>:<add> result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
<del> result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
<13>:<add> result = lc.check(
<del> result = lc.checkLanguage(
<16>:<add> result = lc.check(
<del> result = lc.checkLanguage(
<19>:<add> result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
<0> """
<1> This returns false because s.d is not over 1 as all inputs are English
<2> """
<3> lc = LanguageChecker.LanguageChecker()
<4> result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
<5> result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
<6> result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
<7> result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
<8> result = lc.checkLanguage(
<9> "oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
<10> )
<11> result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
<12> result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
<13> result = lc.checkLanguage(
<14> "posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
<15> )
<16> result = lc.checkLanguage(
<17> "Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
<18> )
<19> result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
<20> result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
<21> result = lc.checkLanguage("das te y we fdsbfsd fe a ")
<22> result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
<23> result = lc.checkLanguage(</s>
|
===========below chunk 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
)
self.assertEqual(result, True)
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 3===========
+ # module: ciphey.basemods
+
+
===========changed ref 4===========
+ # module: ciphey.iface
+
+
===========changed ref 5===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 6===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 7===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 9===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 13===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 15===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 18===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 21===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 22===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 24===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 25===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 26===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 27===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 28===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 29===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 31===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
|
tests.integration/testIntegration.test_integration_unusual_one
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
<del> result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
<2> self.assertEqual(result, True)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 5===========
+ # module: ciphey.basemods
+
+
===========changed ref 6===========
+ # module: ciphey.iface
+
+
===========changed ref 7===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 9===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 11===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 15===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
|
tests.integration/testIntegration.test_integration_unusual_two
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
<del> result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 6===========
+ # module: ciphey.basemods
+
+
===========changed ref 7===========
+ # module: ciphey.iface
+
+
===========changed ref 8===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 10===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 12===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 16===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
|
tests.integration/testIntegration.test_integration_unusual_three
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check("")
<del> result = lc.checkLanguage("")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 7===========
+ # module: ciphey.basemods
+
+
===========changed ref 8===========
+ # module: ciphey.iface
+
+
===========changed ref 9===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 11===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 13===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
|
tests.integration/testIntegration.test_integration_unusual_four
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check(".")
<del> result = lc.checkLanguage(".")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_four(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage(".")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 7===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 8===========
+ # module: ciphey.basemods
+
+
===========changed ref 9===========
+ # module: ciphey.iface
+
+
===========changed ref 10===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 12===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 14===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
|
tests.integration/testIntegration.test_integration_unusual_five
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check("#")
<del> result = lc.checkLanguage("#")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_five(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("#")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_four(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(".")
- result = lc.checkLanguage(".")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 7===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 8===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 9===========
+ # module: ciphey.basemods
+
+
===========changed ref 10===========
+ # module: ciphey.iface
+
+
===========changed ref 11===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 12===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 13===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
|
tests.integration/testIntegration.test_integration_unusual_7
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<1>:<add> result = lc.check(" ")
<del> result = lc.checkLanguage(" ")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_7(self):
<0> lc = LanguageChecker.LanguageChecker()
<1> result = lc.checkLanguage("")
<2> self.assertEqual(result, False)
<3>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_five(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("#")
- result = lc.checkLanguage("#")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_four(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(".")
- result = lc.checkLanguage(".")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 7===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 8===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
===========changed ref 9===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
# offset: 1
<s> = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas oihd "
)
+ result = lc.check(
- result = lc.checkLanguage(
"Likwew e wqrew rwr safdsa dawe r3d hg jyrt dwqefp ;g;;' [ [sadqa ]]."
)
+ result = lc.check("Her hyt e jytgv urjfdghbsfd c ")
- result = lc.checkLanguage("Her hyt e jytgv urjfdghbsfd c ")
+ result = lc.check("CASSAE X T H WAEASD AFDG TERFADDSFD")
- result = lc.checkLanguage("CASSAE X T H WAEASD AFDG TERFADDSFD")
+ result = lc.check("das te y we fdsbfsd fe a ")
- result = lc.checkLanguage("das te y we fdsbfsd fe a ")
+ result = lc.check("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
- result = lc.checkLanguage("d pa pdpsa ofoiaoew ifdisa ikrkasd s")
+ result = lc.check(
- result = lc.checkLanguage(
"My friend is a really nice people who really enjoys swimming, dancing, kicking, English."
)
self.assertEqual(result, True)
===========changed ref 10===========
+ # module: ciphey.basemods
+
+
===========changed ref 11===========
+ # module: ciphey.iface
+
+
===========changed ref 12===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
|
tests.integration/testIntegration.test_integration_addition
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<3>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<4>:<add> result = lc.check("hello my darling")
<del> result = lc.checkLanguage("hello my darling")
<6>:<add> lc2 = LanguageChecker.Checker()
<del> lc2 = LanguageChecker.LanguageChecker()
<7>:<add> result = lc.check("sad as dasr as s")
<del> result = lc.checkLanguage("sad as dasr as s")
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_addition(self):
<0> """
<1> Makes sure you can add 2 lanuggae objecs together
<2> """
<3> lc = LanguageChecker.LanguageChecker()
<4> result = lc.checkLanguage("hello my darling")
<5>
<6> lc2 = LanguageChecker.LanguageChecker()
<7> result = lc.checkLanguage("sad as dasr as s")
<8>
<9> temp = lc.getChiScore()
<10> temp2 = lc2.getChiScore()
<11> temp3 = temp + temp2
<12> lc3 = lc + lc2
<13>
<14> self.assertAlmostEqual(lc3.getChiScore(), temp3)
<15>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertAlmostEqual(first: float, second: float, places: Optional[int]=..., msg: Any=..., delta: Optional[float]=...) -> None
assertAlmostEqual(first: datetime.datetime, second: datetime.datetime, places: Optional[int]=..., msg: Any=..., delta: Optional[datetime.timedelta]=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_five(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("#")
- result = lc.checkLanguage("#")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_four(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(".")
- result = lc.checkLanguage(".")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_7(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 7===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 8===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 9===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
|
tests.integration/testIntegration.test_integration_charlesBabbage
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<5>:<add> lc = LanguageChecker.Checker()
<del> lc = LanguageChecker.LanguageChecker()
<6>:<add> result = lc.check(text)
<del> result = lc.checkLanguage(text)
|
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_charlesBabbage(self):
<0> """
<1> I had a bug with this exact string
<2> Bug is that chi squared does not score this as True
<3> """
<4> 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."""
<5> lc = LanguageChecker.LanguageChecker()
<6> result = lc.checkLanguage(text)
<7> self.assertEqual(result, True)
<8>
|
===========unchanged ref 0===========
at: unittest.case.TestCase
assertEqual(first: Any, second: Any, msg: Any=...) -> None
===========changed ref 0===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_five(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("#")
- result = lc.checkLanguage("#")
self.assertEqual(result, False)
===========changed ref 1===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_four(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(".")
- result = lc.checkLanguage(".")
self.assertEqual(result, False)
===========changed ref 2===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_three(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 3===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_7(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("")
- result = lc.checkLanguage("")
self.assertEqual(result, False)
===========changed ref 4===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_one(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
- result = lc.checkLanguage("HELLO MY NAME IS BRANDON AND I LIKE DOLLAR")
self.assertEqual(result, True)
===========changed ref 5===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_unusual_two(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- result = lc.checkLanguage("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
self.assertEqual(result, False)
===========changed ref 6===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_german(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hallo keine lieben leute nach")
- result = lc.checkLanguage("hallo keine lieben leute nach")
self.assertEqual(result, False)
===========changed ref 7===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics(self):
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check(
- result = lc.checkLanguage(
"Hello my name is new and this is an example of some english text"
)
self.assertEqual(result, True)
===========changed ref 8===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_integration_addition(self):
"""
Makes sure you can add 2 lanuggae objecs together
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("hello my darling")
- result = lc.checkLanguage("hello my darling")
+ lc2 = LanguageChecker.Checker()
- lc2 = LanguageChecker.LanguageChecker()
+ result = lc.check("sad as dasr as s")
- result = lc.checkLanguage("sad as dasr as s")
temp = lc.getChiScore()
temp2 = lc2.getChiScore()
temp3 = temp + temp2
lc3 = lc + lc2
self.assertAlmostEqual(lc3.getChiScore(), temp3)
===========changed ref 9===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_basics_quickbrownfox(self):
"""
This returns true becaue by default chi squared returns true so long as it's less than 10 items it's processed
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("The quick brown fox jumped over the lazy dog")
- result = lc.checkLanguage("The quick brown fox jumped over the lazy dog")
self.assertEqual(result, True)
===========changed ref 10===========
# module: tests.integration
class testIntegration(unittest.TestCase):
def test_chi_maxima_true(self):
"""
This returns false because s.d is not over 1 as all inputs are English
"""
+ lc = LanguageChecker.Checker()
- lc = LanguageChecker.LanguageChecker()
+ result = lc.check("sa dew fea dxza dcsa da fsa d")
- result = lc.checkLanguage("sa dew fea dxza dcsa da fsa d")
+ result = lc.check("df grtsf a sgrds fgserwqd")
- result = lc.checkLanguage("df grtsf a sgrds fgserwqd")
+ result = lc.check("fd sa fe safsda srmad sadsa d")
- result = lc.checkLanguage("fd sa fe safsda srmad sadsa d")
+ result = lc.check(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
- result = lc.checkLanguage(" oihn giuhh7hguygiuhuyguyuyg ig iug iugiugiug")
+ result = lc.check(
- result = lc.checkLanguage(
"oiuhiuhiuhoiuh7 a opokp[poj uyg ytdra4efriug oih kjnbjhb jgv"
)
+ result = lc.check("r jabbi tb y jyg ygiuygytff u0")
- result = lc.checkLanguage("r jabbi tb y jyg ygiuygytff u0")
+ result = lc.check("ld oiu oj uh t t er s d gf hg g h h")
- result = lc.checkLanguage("ld oiu oj uh t t er s d gf hg g h h")
+ result = lc.check(
- result = lc.checkLanguage(
"posa idijdsa ije i vi ijerijofdj ouhsaf oiuhas</s>
|
ciphey.Decryptor.basicEncryption.caesar/Caesar.decrypt
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<16>:<add> result = self.lc.check(translated)
<del> result = self.lc.checkLanguage(translated)
|
# module: ciphey.Decryptor.basicEncryption.caesar
class Caesar:
def decrypt(self, message):
<0> logger.debug("Trying caesar Cipher")
<1> # Convert it to lower case
<2> #
<3> # TODO: handle different alphabets
<4> message = message.lower()
<5>
<6> # Hand it off to the core
<7> group = cipheydists.get_charset("english")["lcase"]
<8> expected = cipheydists.get_dist("lcase")
<9> analysis = cipheycore.analyse_string(message)
<10> possible_keys = cipheycore.caesar_crack(analysis, expected, group)
<11> n_candidates = len(possible_keys)
<12> logger.debug(f"Caesar cipher core heuristic returned {n_candidates} candidates")
<13>
<14> for candidate in possible_keys:
<15> translated = cipheycore.caesar_decrypt(message, candidate.key, group)
<16> result = self.lc.checkLanguage(translated)
<17> if result:
<18> logger.debug(f"Caesar cipher returns true {result}")
<19> return {
<20> "lc": self.lc,
<21> "IsPlaintext?": True,
<22> "Plaintext": translated,
<23> "Cipher": "Caesar",
<24> "Extra Information": f"The rotation used is {candidate.key}",
<25> }
<26>
<27> # if none of them match English, return false!
<28> logger.debug(f"Caesar cipher returns false")
<29> return {
<30> "lc": self.lc,
<31> "IsPlaintext?": False,
<32> "Plaintext": None,
<33> "Cipher": "Caesar",
<34> "Extra Information": None,
<35> }
<36>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.caesar.Caesar.__init__
self.lc = lc
===========changed ref 0===========
+ # module: ciphey.basemods
+
+
===========changed ref 1===========
+ # module: ciphey.iface
+
+
===========changed ref 2===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 3===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 4===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 5===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 6===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 7===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 10===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 12===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 18===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 21===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 22===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 24===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 25===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 26===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 28===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 29===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __le__(self, other: "DecoderComparer"):
+ return self.value.priority() <= other.value.priority()
+
===========changed ref 32===========
<s>, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @staticmethod
+ @abstractmethod
+ def priority() -> float:
+ """What proportion of decodings are this?"""
+ pass
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ T = TypeVar("T")
+ U = TypeVar("U")
+
===========changed ref 34===========
+ # module: ciphey.iface._modules
+ class Targeted(ABC):
+ @staticmethod
+ @abstractmethod
+ def getTarget() -> str:
+ """Should return the target that this object attacks/decodes"""
+ pass
+
===========changed ref 35===========
+ # module: ciphey.iface._config
+ class Config:
+ def update_format(self, paramname: str, value: Optional[Any]):
+ if value is not None:
+ self.format[paramname] = value
+
|
ciphey.Decryptor.basicEncryption.transposition/Transposition.hackTransposition
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<6>:<add> result = self.lc.check(decryptedText)
<del> result = self.lc.checkLanguage(decryptedText)
|
# 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
===========changed ref 0===========
+ # module: ciphey.basemods
+
+
===========changed ref 1===========
+ # module: ciphey.iface
+
+
===========changed ref 2===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 3===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 4===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 5===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 6===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 7===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 8===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 9===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 10===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 11===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 12===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 13===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 15===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 18===========
<s>str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 20===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.attemptCrack(*args)
+
===========changed ref 21===========
+ # module: ciphey.iface._fwd
+ registry = None
+ config = type(None)
+
===========changed ref 22===========
+ # module: ciphey.iface._registry
+ class Registry:
+ def register(self, input_type):
+ self._real_register(input_type)
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class SearchLevel(NamedTuple):
+ name: str
+ result: CrackResult
+
===========changed ref 24===========
+ # module: entry_point
+ if __name__ == "__main__":
+ main()
+
===========changed ref 25===========
# module: ciphey.__main__
- class Ciphey:
- config = dict()
- params = dict()
-
===========changed ref 26===========
+ # module: ciphey.iface._config
+ def split_resource_name(full_name: str) -> (str, str):
+ return full_name.split("::", 1)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def search(self, ctext: Any) -> SearchResult:
+ """Returns the path to the correct ciphertext"""
+ pass
+
===========changed ref 28===========
+ # module: ciphey.iface._config
+ class Config:
+ @staticmethod
+ def get_default_dir() -> str:
+ return appdirs.user_config_dir("ciphey")
+
===========changed ref 29===========
+ # module: ciphey.iface._modules
+ class SearchResult(NamedTuple):
+ path: List[SearchLevel]
+ check_res: str
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __ge__(self, other: "DecoderComparer"):
+ return self.value.priority() >= other.value.priority()
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __le__(self, other: "DecoderComparer"):
+ return self.value.priority() <= other.value.priority()
+
===========changed ref 32===========
<s>, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @staticmethod
+ @abstractmethod
+ def priority() -> float:
+ """What proportion of decodings are this?"""
+ pass
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ T = TypeVar("T")
+ U = TypeVar("U")
+
===========changed ref 34===========
+ # module: ciphey.iface._modules
+ class Targeted(ABC):
+ @staticmethod
+ @abstractmethod
+ def getTarget() -> str:
+ """Should return the target that this object attacks/decodes"""
+ pass
+
===========changed ref 35===========
+ # module: ciphey.iface._config
+ class Config:
+ def update_format(self, paramname: str, value: Optional[Any]):
+ if value is not None:
+ self.format[paramname] = value
+
|
ciphey.Decryptor.basicEncryption.pigLatin/PigLatin.decrypt
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
# 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> logger.debug(f"Pig Latin is less than 3 so returning false")
<5> return {
<6> "lc": self.lc,
<7> "IsPlaintext?": False,
<8> "Plaintext": None,
<9> "Cipher": "Pig Latin",
<10> "Extra Information": None,
<11> }
<12>
<13> else:
<14> messagePIGWAY = message
<15>
<16> messagePIGAY = message[0 : len(message) - 2]
<17> # takes the last 2 letters of message
<18> message2AY = messagePIGAY[-1]
<19> # takes last letter of word and puts it into a variable
<20> messagePIGAY = messagePIGAY[0 : len(messagePIGAY) - 1]
<21> # removes the last letter of the word
<22> message3AY = message2AY + messagePIGAY
<23> # creates a varaible which has the previous last letter as the first and
<24> # the rest of the word as the rest of it. This is one way to do Pig Latin.
<25>
<26> messagePIGWAY1 = messagePIGWAY[0 : len(messagePIGWAY) - 3]
<27> # takes the last 3 letters of message
<28> message2WAY = messagePIGWAY1
<29> # copies varaibles
<30> message2WAY = message2WAY[-1]
<31> # takes last letter of word and puts it into a variable
<32> messagePIGWAY1 = messagePIGWAY1[0 : len(messagePIGWAY1) - 1]
<33> #</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.basicEncryption.pigLatin
class PigLatin:
def decrypt(self, message):
# offset: 1
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,
}
===========unchanged ref 0===========
at: ciphey.Decryptor.basicEncryption.pigLatin.PigLatin.__init__
self.lc = lc
===========changed ref 0===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 1===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 3===========
+ # module: ciphey.common
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 6===========
+ # module: ciphey.basemods
+
+
===========changed ref 7===========
+ # module: ciphey.iface
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 9===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 11===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 12===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 13===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 14===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 15===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 16===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 17===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 18===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 20===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 21===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 22===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 24===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 25===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
+ @registry.register
+ class Brandon(ciphey.iface.Checker[str]):
+
+ wordlist: set
+
===========changed ref 26===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 28===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ def __init__(self, config: ciphey.iface.Config):
+ super().__init__(config)
+
|
|
ciphey.Decryptor.Encoding.ascii/Ascii.decrypt
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<20>:<add> if self.lc.check(result):
<del> if self.lc.checkLanguage(result):
|
# module: ciphey.Decryptor.Encoding.ascii
class Ascii:
def decrypt(self, text):
<0> logger.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> logger.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
===========changed ref 0===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 1===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 3===========
+ # module: ciphey.common
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 6===========
+ # module: ciphey.basemods
+
+
===========changed ref 7===========
+ # module: ciphey.iface
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 9===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 10===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 11===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 12===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 13===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 14===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 15===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 16===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 17===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 18===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 19===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 20===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 21===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 22===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 24===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 25===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
+ @registry.register
+ class Brandon(ciphey.iface.Checker[str]):
+
+ wordlist: set
+
===========changed ref 26===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 28===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ def __init__(self, config: ciphey.iface.Config):
+ super().__init__(config)
+
===========changed ref 29===========
+ # module: ciphey.iface._config
+ class Config:
+ def __call__(self, t: type) -> Any:
+ return self.instantiate(t)
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class Searcher(ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __getitem__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ class ResourceLoader(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.getResource(*args)
+
===========changed ref 34===========
+ # module: ciphey.iface._modules
+ class Cracker(Generic[T], ConfigurableModule, Targeted):
+ @abstractmethod
+ def __init__(self, config: Config):
+ super().__init__(config)
+
|
ciphey.Decryptor.Hash.hashBuster/crack
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<6>:<add> result = lc.check(r) if r is not None else None
<del> result = lc.checkLanguage(r) if r is not None else None
<19>:<add> result = lc.check(r) if r is not None else None
<del> result = lc.checkLanguage(r) if r is not None else None
<32>:<add> result = lc.check(r) if r is not None else None
<del> result = lc.checkLanguage(r) if r is not None else None
|
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
<0>
<1> logger.debug(f"Starting to crack hashes")
<2> result = False
<3> if len(hashvalue) == 32:
<4> for api in md5:
<5> r = api(hashvalue, "md5")
<6> result = lc.checkLanguage(r) if r is not None else None
<7> if result is not None or r is not None:
<8> logger.debug(f"MD5 returns True {r}")
<9> return {
<10> "lc": None,
<11> "IsPlaintext?": True,
<12> "Plaintext": r,
<13> "Cipher": "md5",
<14> "Extra Information": None,
<15> }
<16> elif len(hashvalue) == 40:
<17> for api in sha1:
<18> r = api(hashvalue, "sha1")
<19> result = lc.checkLanguage(r) if r is not None else None
<20> if result is not None and r is not None:
<21> logger.debug(f"sha1 returns true")
<22> return {
<23> "lc": None,
<24> "IsPlaintext?": True,
<25> "Plaintext": r,
<26> "Cipher": "sha1",
<27> "Extra Information": None,
<28> }
<29> elif len(hashvalue) == 64:
<30> for api in sha256:
<31> r = api(hashvalue, "sha256")
<32> result = lc.checkLanguage(r) if r is not None else None
<33> if result is not None and r is not None:
<34> logger.debug(f"sha256 returns true")
<35> return {
<36> "lc": None,
<37> "IsPlaintext?": True,
<38> "Plaintext": r,
<39> "Cipher": "sha256",
<40> "Extra Information": None,
<41> }
</s>
|
===========below chunk 0===========
# module: ciphey.Decryptor.Hash.hashBuster
def crack(hashvalue, lc):
# offset: 1
for api in sha384:
r = api(hashvalue, "sha384")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha384 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha384",
"Extra Information": None,
}
elif len(hashvalue) == 128:
for api in sha512:
r = api(hashvalue, "sha512")
result = lc.checkLanguage(r) if r is not None else None
if result is not None and r is not None:
logger.debug(f"sha512 returns true")
return {
"lc": None,
"IsPlaintext?": True,
"Plaintext": r,
"Cipher": "sha512",
"Extra Information": None,
}
logger.debug(f"Returning None packet")
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.basemods.Searchers.ausearch
+
+
===========changed ref 1===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 5===========
+ # module: ciphey.common
+
+
===========changed ref 6===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 7===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 8===========
+ # module: ciphey.basemods
+
+
===========changed ref 9===========
+ # module: ciphey.iface
+
+
===========changed ref 10===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 11===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 12===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 13===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 14===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 15===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 16===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 17===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 18===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 19===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 20===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 21===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 22===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 24===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 25===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 26===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 28===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 29===========
+ # module: ciphey.basemods.Crackers.vigenere
+ @registry.register
+ class Vigenere(ciphey.iface.Cracker[str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "vigenere"
+
===========changed ref 30===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
+ @registry.register
+ class Brandon(ciphey.iface.Checker[str]):
+
+ wordlist: set
+
|
ciphey.Decryptor.Encoding.encodingParent/EncodingParent.__init__
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<1>:<del> self.base64 = Bases(self.lc)
|
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
def __init__(self, lc):
<0> self.lc = lc
<1> self.base64 = Bases(self.lc)
<2> self.binary = Binary(self.lc)
<3> self.hex = Hexadecimal(self.lc)
<4> self.ascii = Ascii(self.lc)
<5> self.morse = MorseCode(self.lc)
<6> self.octal = Octal(self.lc)
<7>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.ascii
Ascii(lc)
at: ciphey.Decryptor.Encoding.bases
Bases(lc)
at: ciphey.Decryptor.Encoding.octal
Octal(lc)
===========changed ref 0===========
+ # module: ciphey.Decryptor.Encoding.letters
+
+
===========changed ref 1===========
+ # module: ciphey.basemods.Searchers.ausearch
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 6===========
+ # module: ciphey.common
+
+
===========changed ref 7===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 9===========
+ # module: ciphey.basemods
+
+
===========changed ref 10===========
+ # module: ciphey.iface
+
+
===========changed ref 11===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __init__(self):
+ None
+
===========changed ref 12===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 13===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 14===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 15===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 16===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 17===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def decrypt(self, text: str) -> dict:
+ return text
+
===========changed ref 18===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 19===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 20===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 21===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 22===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 23===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 24===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __name__(self):
+ return "Letters"
+
===========changed ref 25===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 26===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 27===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 28===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 29===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 30===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 33===========
+ # module: ciphey.basemods.Crackers.vigenere
+ @registry.register
+ class Vigenere(ciphey.iface.Cracker[str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "vigenere"
+
===========changed ref 34===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
+ @registry.register
+ class Brandon(ciphey.iface.Checker[str]):
+
+ wordlist: set
+
===========changed ref 35===========
<s>text: T) -> Dict[str, float]:
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ def __call__(self, *args):
+ return self.decode(*args)
+
===========changed ref 36===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ def __call__(self, *args):
+ return self.check(*args)
+
===========changed ref 37===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ def __init__(self, config: ciphey.iface.Config):
+ super().__init__(config)
+
|
ciphey.Decryptor.Encoding.encodingParent/EncodingParent.decrypt
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<18>:<add> # adds the Checkers objects together
<del> # adds the LC objects together
|
# 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, self.octal]
<2> logger.debug(f"Encoding parent is running {torun}")
<3> """
<4> ok so I have an array of functions
<5> and I want to apply each function to some text
<6> (text, function)
<7> but the way it works is you apply text to every item in the array (function)
<8>
<9> """
<10> # from multiprocessing.dummy import Pool as ThreadPool
<11>
<12> # pool = ThreadPool(4)
<13> # answers = pool.map(self.callDecrypt, torun) # It's not worth the thread overhead
<14> answers = map(self.callDecrypt, torun)
<15>
<16> for answer in answers:
<17> logger.debug(f"All answers are {answers}")
<18> # adds the LC objects together
<19> # self.lc = self.lc + answer["lc"]
<20> if answer is not None and answer["IsPlaintext?"]:
<21> logger.debug(f"Plaintext found {answer}")
<22> return answer
<23> return {
<24> "lc": self.lc,
<25> "IsPlaintext?": False,
<26> "Plaintext": None,
<27> "Cipher": None,
<28> "Extra Information": None,
<29> }
<30>
|
===========unchanged ref 0===========
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent
callDecrypt(obj)
at: ciphey.Decryptor.Encoding.encodingParent.EncodingParent.__init__
self.lc = lc
self.base64 = Bases(self.lc)
self.binary = Binary(self.lc)
self.hex = Hexadecimal(self.lc)
self.ascii = Ascii(self.lc)
self.morse = MorseCode(self.lc)
self.octal = Octal(self.lc)
===========changed ref 0===========
# module: ciphey.Decryptor.Encoding.encodingParent
class EncodingParent:
def __init__(self, lc):
self.lc = lc
- self.base64 = Bases(self.lc)
self.binary = Binary(self.lc)
self.hex = Hexadecimal(self.lc)
self.ascii = Ascii(self.lc)
self.morse = MorseCode(self.lc)
self.octal = Octal(self.lc)
===========changed ref 1===========
+ # module: ciphey.Decryptor.Encoding.letters
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Searchers.ausearch
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 6===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 7===========
+ # module: ciphey.common
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 9===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 10===========
+ # module: ciphey.basemods
+
+
===========changed ref 11===========
+ # module: ciphey.iface
+
+
===========changed ref 12===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __init__(self):
+ None
+
===========changed ref 13===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 14===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 15===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 16===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 17===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 18===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def decrypt(self, text: str) -> dict:
+ return text
+
===========changed ref 19===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 20===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 21===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 22===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 23===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 24===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 25===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __name__(self):
+ return "Letters"
+
===========changed ref 26===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 27===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 28===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 29===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 30===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 31===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 32===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 33===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 34===========
+ # module: ciphey.basemods.Crackers.vigenere
+ @registry.register
+ class Vigenere(ciphey.iface.Cracker[str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "vigenere"
+
===========changed ref 35===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
+ @registry.register
+ class Brandon(ciphey.iface.Checker[str]):
+
+ wordlist: set
+
|
tests.enciphey/encipher.__init__
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<2>:<add> self.MAX_SENTENCE_LENGTH = 5
<del> self.MAX_SENTENCE_LENGTH = 20
|
# module: tests.enciphey
class encipher:
def __init__(self):
<0> """Inits the encipher object """
<1> self.text = self.read_text()
<2> self.MAX_SENTENCE_LENGTH = 20
<3> # ntlk.download("punkt")
<4> self.crypto = encipher_crypto()
<5>
|
===========unchanged ref 0===========
at: tests.enciphey
encipher_crypto()
at: tests.enciphey.encipher
read_text()
===========changed ref 0===========
+ # module: ciphey.basemods.Searchers.perfection
+
+
===========changed ref 1===========
+ # module: ciphey.basemods.Resources.cipheydists
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Resources
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Checkers
+
+
===========changed ref 4===========
+ # module: ciphey.Decryptor.Encoding.letters
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Searchers.ausearch
+
+
===========changed ref 6===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 7===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 9===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 10===========
+ # module: ciphey.common
+
+
===========changed ref 11===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 12===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 13===========
+ # module: ciphey.basemods
+
+
===========changed ref 14===========
+ # module: ciphey.iface
+
+
===========changed ref 15===========
+ # module: ciphey.basemods.Searchers.perfection
+ @registry.register
+ class Perfection(AuSearch):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 16===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 17===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> Optional[Set[str]]:
+ pass
+
===========changed ref 18===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __init__(self):
+ None
+
===========changed ref 19===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 20===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 21===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 22===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 23===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 24===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def decrypt(self, text: str) -> dict:
+ return text
+
===========changed ref 25===========
+ # module: ciphey.basemods.Searchers.astar
+ class Node:
+ def get_edges(self):
+ return self.edges
+
===========changed ref 26===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 27===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 28===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 29===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 30===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 31===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 32===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __name__(self):
+ return "Letters"
+
===========changed ref 33===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 34===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 35===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 36===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 37===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
===========changed ref 38===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ value: Type[Decoder]
+
===========changed ref 39===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _config(self):
+ return self._config_obj
+
===========changed ref 40===========
+ # module: ciphey.iface._modules
+ class ConfigurableModule(ABC):
+ def _params(self):
+ return self._params_obj
+
===========changed ref 41===========
+ # module: ciphey.basemods.Searchers.perfection
+ @registry.register
+ class Perfection(AuSearch):
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ return next(iter(nodes))
+
===========changed ref 42===========
+ # module: ciphey.basemods.Crackers.vigenere
+ @registry.register
+ class Vigenere(ciphey.iface.Cracker[str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "vigenere"
+
|
tests.enciphey/encipher.getRandomSentence
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<1>:<add> random.sample(self.text, random.randint(1, size))
<del> random.sample(self.text, random.randint(1, self.MAX_SENTENCE_LENGTH))
|
# module: tests.enciphey
class encipher:
+ def getRandomSentence(self, size):
- def getRandomSentence(self):
<0> return TreebankWordDetokenizer().detokenize(
<1> random.sample(self.text, random.randint(1, self.MAX_SENTENCE_LENGTH))
<2> )
<3>
|
===========unchanged ref 0===========
at: nltk.tokenize.treebank
TreebankWordDetokenizer()
at: nltk.tokenize.treebank.TreebankWordDetokenizer
_contractions = MacIntyreContractions()
CONTRACTIONS2 = [
re.compile(pattern.replace("(?#X)", r"\s"))
for pattern in _contractions.CONTRACTIONS2
]
CONTRACTIONS3 = [
re.compile(pattern.replace("(?#X)", r"\s"))
for pattern in _contractions.CONTRACTIONS3
]
ENDING_QUOTES = [
(re.compile(r"([^' ])\s('ll|'LL|'re|'RE|'ve|'VE|n't|N'T) "), r"\1\2 "),
(re.compile(r"([^' ])\s('[sS]|'[mM]|'[dD]|') "), r"\1\2 "),
(re.compile(r"(\S)\s(\'\')"), r"\1\2"),
(
re.compile(r"(\'\')\s([.,:)\]>};%])"),
r"\1\2",
), # Quotes followed by no-left-padded punctuations.
(re.compile(r"''"), '"'),
]
DOUBLE_DASHES = (re.compile(r" -- "), r"--")
CONVERT_PARENTHESES = [
(re.compile("-LRB-"), "("),
(re.compile("-RRB-"), ")"),
(re.compile("-LSB-"), "["),
(re.compile("-RSB-"), "]"),
(re.compile("-LCB-"), "{"),
(re.compile("-RCB-"), "}"),
]
===========unchanged ref 1===========
PARENS_BRACKETS = [
(re.compile(r"([\[\(\{\<])\s"), r"\g<1>"),
(re.compile(r"\s([\]\)\}\>])"), r"\g<1>"),
(re.compile(r"([\]\)\}\>])\s([:;,.])"), r"\1\2"),
]
PUNCTUATION = [
(re.compile(r"([^'])\s'\s"), r"\1' "),
(re.compile(r"\s([?!])"), r"\g<1>"), # Strip left pad for [?!]
# (re.compile(r'\s([?!])\s'), r'\g<1>'),
(re.compile(r'([^\.])\s(\.)([\]\)}>"\']*)\s*$'), r"\1\2\3"),
# When tokenizing, [;@#$%&] are padded with whitespace regardless of
# whether there are spaces before or after them.
# But during detokenization, we need to distinguish between left/right
# pad, so we split this up.
(re.compile(r"([#$])\s"), r"\g<1>"), # Left pad.
(re.compile(r"\s([;%])"), r"\g<1>"), # Right pad.
# (re.compile(r"\s([&*])\s"), r" \g<1> "), # Unknown pad.
(re.compile(r"\s\.\.\.\s"), r"..."),
# (re.compile(r"\s([:,])\s$"), r"\1"), # .strip() takes care of it.
(
re.compile(r"\s([:,])"),
r"\1",
), # Just remove left padding. Punctuation in numbers won't be padded.
]
===========unchanged ref 2===========
STARTING_QUOTES = [
(re.compile(r"([ (\[{<])\s``"), r"\1``"),
(re.compile(r"(``)\s"), r"\1"),
(re.compile(r"``"), r'"'),
]
detokenize(tokens: List[str], convert_parentheses: bool=False) -> str
at: random
randint = _inst.randint
sample = _inst.sample
at: tests.enciphey.encipher.__init__
self.text = self.read_text()
self.MAX_SENTENCE_LENGTH = 20
===========changed ref 0===========
# module: tests.enciphey
class encipher:
def __init__(self):
"""Inits the encipher object """
self.text = self.read_text()
+ self.MAX_SENTENCE_LENGTH = 5
- self.MAX_SENTENCE_LENGTH = 20
# ntlk.download("punkt")
self.crypto = encipher_crypto()
===========changed ref 1===========
+ # module: ciphey.basemods.Searchers.perfection
+
+
===========changed ref 2===========
+ # module: ciphey.basemods.Resources.cipheydists
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Resources
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Checkers
+
+
===========changed ref 5===========
+ # module: ciphey.Decryptor.Encoding.letters
+
+
===========changed ref 6===========
+ # module: ciphey.basemods.Searchers.ausearch
+
+
===========changed ref 7===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 9===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 10===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 11===========
+ # module: ciphey.common
+
+
===========changed ref 12===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 13===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 14===========
+ # module: ciphey.basemods
+
+
===========changed ref 15===========
+ # module: ciphey.iface
+
+
===========changed ref 16===========
+ # module: ciphey.basemods.Searchers.perfection
+ @registry.register
+ class Perfection(AuSearch):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 17===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 18===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> Optional[Set[str]]:
+ pass
+
===========changed ref 19===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __init__(self):
+ None
+
===========changed ref 20===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 21===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 22===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
|
tests.enciphey/encipher.getRandomEncryptedSentence
|
Modified
|
Ciphey~Ciphey
|
b77c4eacd111b3805969e0ed0c8bccd808524009
|
5.0.0 first release (#154)
|
<0>:<add> sents = self.getRandomSentence(size)
<del> sents = self.getRandomSentence()
|
# module: tests.enciphey
class encipher:
+ def getRandomEncryptedSentence(self, size):
- def getRandomEncryptedSentence(self):
<0> sents = self.getRandomSentence()
<1>
<2> sentsEncrypted = self.crypto.randomEncrypt(sents)
<3> return {"PlainText Sentences": sents, "Encrypted Texts": sentsEncrypted}
<4>
|
===========unchanged ref 0===========
at: tests.enciphey.encipher
getRandomSentence()
getRandomSentence(self)
at: tests.enciphey.encipher.__init__
self.crypto = encipher_crypto()
at: tests.enciphey.encipher_crypto
randomEncrypt(text: str) -> str
===========changed ref 0===========
# module: tests.enciphey
class encipher:
+ def getRandomSentence(self, size):
- def getRandomSentence(self):
return TreebankWordDetokenizer().detokenize(
+ random.sample(self.text, random.randint(1, size))
- random.sample(self.text, random.randint(1, self.MAX_SENTENCE_LENGTH))
)
===========changed ref 1===========
# module: tests.enciphey
class encipher:
def __init__(self):
"""Inits the encipher object """
self.text = self.read_text()
+ self.MAX_SENTENCE_LENGTH = 5
- self.MAX_SENTENCE_LENGTH = 20
# ntlk.download("punkt")
self.crypto = encipher_crypto()
===========changed ref 2===========
+ # module: ciphey.basemods.Searchers.perfection
+
+
===========changed ref 3===========
+ # module: ciphey.basemods.Resources.cipheydists
+
+
===========changed ref 4===========
+ # module: ciphey.basemods.Resources
+
+
===========changed ref 5===========
+ # module: ciphey.basemods.Checkers
+
+
===========changed ref 6===========
+ # module: ciphey.Decryptor.Encoding.letters
+
+
===========changed ref 7===========
+ # module: ciphey.basemods.Searchers.ausearch
+
+
===========changed ref 8===========
+ # module: ciphey.basemods.Crackers.vigenere
+
+
===========changed ref 9===========
+ # module: ciphey.basemods.Resources.files
+
+
===========changed ref 10===========
+ # module: ciphey.basemods.Decoders.unicode
+
+
===========changed ref 11===========
+ # module: ciphey.basemods.Checkers.brandon
+
+
===========changed ref 12===========
+ # module: ciphey.common
+
+
===========changed ref 13===========
+ # module: ciphey.basemods.Crackers
+
+
===========changed ref 14===========
+ # module: ciphey.basemods.Searchers
+
+
===========changed ref 15===========
+ # module: ciphey.basemods
+
+
===========changed ref 16===========
+ # module: ciphey.iface
+
+
===========changed ref 17===========
+ # module: ciphey.basemods.Searchers.perfection
+ @registry.register
+ class Perfection(AuSearch):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 18===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 19===========
+ # module: ciphey.basemods.Resources.cipheydists
+ @registry.register_multi(WordList, Distribution)
+ class CipheyDists(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> Optional[Set[str]]:
+ pass
+
===========changed ref 20===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __init__(self):
+ None
+
===========changed ref 21===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @staticmethod
+ @abstractmethod
+ def getParams() -> Optional[Dict[str, ParamSpec]]:
+ pass
+
===========changed ref 22===========
+ # module: ciphey.basemods.Searchers.ausearch
+ class AuSearch(Searcher, ABC):
+ @abstractmethod
+ def findBestNode(self, nodes: Set[Node]) -> Node:
+ pass
+
===========changed ref 23===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getParams() -> Optional[Dict[str, Dict[str, Any]]]:
+ pass
+
===========changed ref 24===========
<s>
+ # """Should return a dictionary of (cipher_name: score)"""
+ # pass
+ #
+ # def __call__(self, *args): return self.scoreLikelihood(*args)
+ #
+ # @abstractmethod
+ # def __init__(self, config: Config): super().__init__(config)
+
+
+ class Decoder(Generic[T, U], ConfigurableModule, Targeted):
+ @abstractmethod
+ def decode(self, ctext: T) -> Optional[U]:
+ pass
+
===========changed ref 25===========
+ # module: ciphey.iface._modules
+ class Checker(Generic[T], ConfigurableModule):
+ @abstractmethod
+ def getExpectedRuntime(self, text: T) -> float:
+ pass
+
===========changed ref 26===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def decrypt(self, text: str) -> dict:
+ return text
+
===========changed ref 27===========
+ # module: ciphey.basemods.Searchers.astar
+ class Node:
+ def get_edges(self):
+ return self.edges
+
===========changed ref 28===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ @staticmethod
+ def getName() -> str:
+ return "csv"
+
===========changed ref 29===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Csv(Generic[T], ciphey.iface.ResourceLoader[T]):
+ def whatResources(self) -> Set[str]:
+ return self._names
+
===========changed ref 30===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ @staticmethod
+ def getName() -> str:
+ return "json"
+
===========changed ref 31===========
+ # module: ciphey.basemods.Resources.files
+ # We can use a generic resource loader here, as we can instantiate it later
+ @registry.register_multi(ciphey.iface.WordList, ciphey.iface.Distribution)
+ class Json(ciphey.iface.ResourceLoader):
+ def whatResources(self) -> T:
+ return self._names
+
===========changed ref 32===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def priority() -> float:
+ return 0.9
+
===========changed ref 33===========
+ # module: ciphey.common
+ """Some useful adapters"""
+
===========changed ref 34===========
+ # module: ciphey.Decryptor.Encoding.letters
+ class letters:
+ def __name__(self):
+ return "Letters"
+
===========changed ref 35===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getTarget() -> str:
+ return "utf8"
+
===========changed ref 36===========
+ # module: ciphey.iface._config
+ _fwd.config = Config
+
===========changed ref 37===========
+ # module: ciphey.iface._modules
+ class DecoderComparer:
+ def __init__(self, value: Type[Decoder]):
+ self.value = value
+
===========changed ref 38===========
+ # module: ciphey.basemods.Decoders.unicode
+ @registry.register
+ class Utf8(ciphey.iface.Decoder[bytes, str]):
+ @staticmethod
+ def getName() -> str:
+ return "UTF-8"
+
===========changed ref 39===========
+ # module: ciphey.iface._registry
+ _fwd.registry = Registry()
+
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
87114b9887b4c28e1dff397974714a5a642724da
|
initial upload
|
<29>:<del>
<33>:<add> dirs = AppDirs("Ciphey", "Ciphey")
<add> print(f"The settings.yml file location should be {dirs.user_config_dir}")
<del> import appdirs
<34>:<del> appname = "
|
<s>Adds a module from the given path", type=click.Path(), multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
+ type=bool,
- type=bool
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU=" -d true -c true
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29>
<30> # if user wants to know where appdirs is
<31> # print and exit
<32> if kwargs["appdirs"] is not None:
<33> import appdirs
<34> appname = "</s>
|
===========below chunk 0===========
<s> given path", type=click.Path(), multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
+ type=bool,
- type=bool
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 1
return None
# Now we create the config object
config = iface.Config()
# Default init the config object
config = iface.Config()
# Load the settings file into the config
cfg_arg = kwargs["config"]
if cfg_arg is None:
# Make sure that the config dir actually exists
os.makedirs(iface.Config.get_default_dir(), exist_ok=True)
config.load_file(create=True)
else:
config.load_file(cfg_arg)
# Load the verbosity, so that we can start logging
verbosity = kwargs["verbose"]
quiet = kwargs["quiet"]
if verbosity is None:
if quiet is not None:
verbosity = -quiet
elif quiet is not None:
verbosity -= quiet
if kwargs["greppable"] is not None:
verbosity -= 999
# Use the existing value as a base
config.verbosity += verbosity
config.update_log_level(config.verbosity)
logger.trace(f"Got cmdline args {kwargs}")
# Now we load the modules
module_arg = kwargs["module"]
if module_arg is not None:
config.modules += list(module_arg)
config.load_modules()
# We need to load formats BEFORE we instantiate objects
if kwargs["bytes_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes_output"]
if kwargs["bytes_output"] is not None:
config.update_format("</s>
===========below chunk 1===========
<s> given path", type=click.Path(), multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
+ type=bool,
- type=bool
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 2
<s>_format = kwargs["bytes_output"]
if kwargs["bytes_output"] is not None:
config.update_format("in", "bytes")
# Next, load the objects
params = kwargs["param"]
if params is not None:
for i in params:
key, value = i.split("=", 1)
parent, name = key.split(".", 1)
config.update_param(parent, name, value)
config.update("checker", kwargs["checker"])
config.update("searcher", kwargs["searcher"])
config.update("default_dist", kwargs["default_dist"])
config.load_objs()
logger.trace(f"Config finalised: {config}")
# Finally, we load the plaintext
if kwargs["text"] is None:
if kwargs["file_stdin"] is not None:
kwargs["text"] = kwargs["file_stdin"].read().decode("utf-8")
elif kwargs["text_stdin"] is not None:
kwargs["text"] = kwargs["text_stdin"]
else:
print("No inputs were given to Ciphey. For usage, run ciphey --help")
logger.critical("No text input given!")
return None
print(decrypt(config, kwargs["text"]))
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
1167e39a201e4d6686d0ecd7a2a6fe8d6f282fa1
|
added a spinner
|
<s> help="Adds a module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU=" -d true -c true
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> # if user wants to know where appdirs is
<30> # print and exit
<31> if kwargs["appdirs"] is not None:
<32> dirs = AppDirs("Ciphey", "C</s>
|
===========below chunk 0===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 1
print(f"The settings.yml file location should be {dirs.user_config_dir}")
return None
# Now we create the config object
config = iface.Config()
# Default init the config object
config = iface.Config()
# Load the settings file into the config
cfg_arg = kwargs["config"]
if cfg_arg is None:
# Make sure that the config dir actually exists
os.makedirs(iface.Config.get_default_dir(), exist_ok=True)
config.load_file(create=True)
else:
config.load_file(cfg_arg)
# Load the verbosity, so that we can start logging
verbosity = kwargs["verbose"]
quiet = kwargs["quiet"]
if verbosity is None:
if quiet is not None:
verbosity = -quiet
elif quiet is not None:
verbosity -= quiet
if kwargs["greppable"] is not None:
verbosity -= 999
# Use the existing value as a base
config.verbosity += verbosity
config.update_log_level(config.verbosity)
logger.trace(f"Got cmdline args {kwargs}")
# Now we load the modules
module_arg = kwargs["module"]
if module_arg is not None:
config.modules += list(module_arg)
config.load_modules()
# We need to load formats BEFORE we instantiate objects
if kwargs["bytes_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes</s>
===========below chunk 1===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 2
<s>_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes_output"]
if kwargs["bytes_output"] is not None:
config.update_format("in", "bytes")
# Next, load the objects
params = kwargs["param"]
if params is not None:
for i in params:
key, value = i.split("=", 1)
parent, name = key.split(".", 1)
config.update_param(parent, name, value)
config.update("checker", kwargs["checker"])
config.update("searcher", kwargs["searcher"])
config.update("default_dist", kwargs["default_dist"])
config.load_objs()
logger.trace(f"Config finalised: {config}")
# Finally, we load the plaintext
if kwargs["text"] is None:
if kwargs["file_stdin"] is not None:
kwargs["text"] = kwargs["file_stdin"].read().decode("utf-8")
elif kwargs["text_stdin"] is not None:
kwargs["text"] = kwargs["text_stdin"]
else:
print("No inputs were given to Ciphey. For usage, run ciphey --help")
return None
print(decrypt(config, kwargs["text"]))
|
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
31a6a1e4e9e690eddbe94cd6e36c2a21b8ab65e6
|
unstaged
|
<s> help="Adds a module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU=" -d true -c true
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> # if user wants to know where appdirs is
<30> # print and exit
<31> if kwargs["appdirs"] is not None:
<32> dirs = AppDirs("Ciphey", "C</s>
|
===========below chunk 0===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 1
print(f"The settings.yml file location should be {dirs.user_config_dir}")
return None
# Now we create the config object
config = iface.Config()
# Default init the config object
config = iface.Config()
# Load the settings file into the config
cfg_arg = kwargs["config"]
if cfg_arg is None:
# Make sure that the config dir actually exists
os.makedirs(iface.Config.get_default_dir(), exist_ok=True)
config.load_file(create=True)
else:
config.load_file(cfg_arg)
# Load the verbosity, so that we can start logging
verbosity = kwargs["verbose"]
quiet = kwargs["quiet"]
if verbosity is None:
if quiet is not None:
verbosity = -quiet
elif quiet is not None:
verbosity -= quiet
if kwargs["greppable"] is not None:
verbosity -= 999
# Use the existing value as a base
config.verbosity += verbosity
config.update_log_level(config.verbosity)
logger.trace(f"Got cmdline args {kwargs}")
# Now we load the modules
module_arg = kwargs["module"]
if module_arg is not None:
config.modules += list(module_arg)
config.load_modules()
# We need to load formats BEFORE we instantiate objects
if kwargs["bytes_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes</s>
===========below chunk 1===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 2
<s>_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes_output"]
if kwargs["bytes_output"] is not None:
config.update_format("in", "bytes")
# Next, load the objects
params = kwargs["param"]
if params is not None:
for i in params:
key, value = i.split("=", 1)
parent, name = key.split(".", 1)
config.update_param(parent, name, value)
config.update("checker", kwargs["checker"])
config.update("searcher", kwargs["searcher"])
config.update("default_dist", kwargs["default_dist"])
config.load_objs()
logger.trace(f"Config finalised: {config}")
# Finally, we load the plaintext
if kwargs["text"] is None:
if kwargs["file_stdin"] is not None:
kwargs["text"] = kwargs["file_stdin"].read().decode("utf-8")
elif kwargs["text_stdin"] is not None:
kwargs["text"] = kwargs["text_stdin"]
else:
print("No inputs were given to Ciphey. For usage, run ciphey --help")
return None
with yaspin(Spinners.earth, text="Earth") as sp:
result = decrypt(config, kwargs["text"])
|
|
ciphey.__main__/main
|
Modified
|
Ciphey~Ciphey
|
788d0af2c12d26203baf93777a18f8ad57245be6
|
not sure why pytest is failing
|
<s> help="Adds a module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
<0> """Ciphey - Automated Decryption Tool
<1>
<2> Documentation:
<3> https://docs.ciphey.online\n
<4> Discord (support here, we're online most of the day):
<5> https://discord.ciphey.online/\n
<6> GitHub:
<7> https://github.com/ciphey/ciphey\n
<8>
<9> Ciphey is an automated decryption tool using smart artificial intelligence and natural language processing. Input encrypted text, get the decrypted text back.
<10>
<11> Examples:\n
<12> Basic Usage: ciphey -t "aGVsbG8gbXkgbmFtZSBpcyBiZWU=" -d true -c true
<13>
<14> """
<15>
<16> """Function to deal with arguments. Either calls with args or not. Makes Pytest work.
<17>
<18> It gets the arguments in the function definition using locals()
<19> if withArgs is True, that means this is being called with command line args
<20> so go to arg_parsing() to get those args
<21> we then update locals() with the new command line args and remove "withArgs"
<22> This function then calls call_encryption(**result) which passes our dict of args
<23> to the function as its own arguments using dict unpacking.
<24>
<25> Returns:
<26> The output of the decryption.
<27> """
<28>
<29> # if user wants to know where appdirs is
<30> # print and exit
<31> if kwargs["appdirs"] is not None:
<32> dirs = AppDirs("Ciphey", "C</s>
|
===========below chunk 0===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 1
print(f"The settings.yml file location should be {dirs.user_config_dir}")
return None
# Now we create the config object
config = iface.Config()
# Default init the config object
config = iface.Config()
# Load the settings file into the config
cfg_arg = kwargs["config"]
if cfg_arg is None:
# Make sure that the config dir actually exists
os.makedirs(iface.Config.get_default_dir(), exist_ok=True)
config.load_file(create=True)
else:
config.load_file(cfg_arg)
# Load the verbosity, so that we can start logging
verbosity = kwargs["verbose"]
quiet = kwargs["quiet"]
if verbosity is None:
if quiet is not None:
verbosity = -quiet
elif quiet is not None:
verbosity -= quiet
if kwargs["greppable"] is not None:
verbosity -= 999
# Use the existing value as a base
config.verbosity += verbosity
config.update_log_level(config.verbosity)
logger.trace(f"Got cmdline args {kwargs}")
# Now we load the modules
module_arg = kwargs["module"]
if module_arg is not None:
config.modules += list(module_arg)
config.load_modules()
# We need to load formats BEFORE we instantiate objects
if kwargs["bytes_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes</s>
===========below chunk 1===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 2
<s>_input"] is not None:
config.update_format("in", "bytes")
output_format = kwargs["bytes_output"]
if kwargs["bytes_output"] is not None:
config.update_format("in", "bytes")
# Next, load the objects
params = kwargs["param"]
if params is not None:
for i in params:
key, value = i.split("=", 1)
parent, name = key.split(".", 1)
config.update_param(parent, name, value)
config.update("checker", kwargs["checker"])
config.update("searcher", kwargs["searcher"])
config.update("default_dist", kwargs["default_dist"])
config.load_objs()
logger.trace(f"Config finalised: {config}")
# Finally, we load the plaintext
if kwargs["text"] is None:
if kwargs["file_stdin"] is not None:
kwargs["text"] = kwargs["file_stdin"].read().decode("utf-8")
elif kwargs["text_stdin"] is not None:
kwargs["text"] = kwargs["text_stdin"]
else:
print("No inputs were given to Ciphey. For usage, run ciphey --help")
return None
# if debug mode is on, run without spinner
if config.verbosity > 0:
result = decrypt(config, kwargs["text"])</s>
===========below chunk 2===========
<s> module from the given path",
type=click.Path(),
multiple=True,
)
@click.option(
"-A",
"--appdirs",
help="Print the location of where Ciphey wants the settings file to be",
type=bool,
)
@click.argument("text_stdin", callback=get_name, required=False)
@click.argument("file_stdin", type=click.File("rb"), required=False)
def main(**kwargs) -> Optional[dict]:
# offset: 3
<s> elif config.verbosity == 0:
# else, run with spinner if verbosity is 0
with yaspin(Spinners.earth, text="Earth") as sp:
result = decrypt(config, kwargs["text"])
else:
# else its below 0, so quiet mode is on. make it greppable""
result = decrypt(config, kwargs["text"])
print(result)
|
|
ciphey.iface._modules/pretty_search_results
|
Modified
|
Ciphey~Ciphey
|
f361e801889cd6cd7ecee507c10cba94882017c8
|
Fixed #161 and #160
|
<0>:<add> ret: str = ""
<del> ret: str = f'Final result: "{res.path[-1].result.value}"\n'
<30>:<add> ret += (
<add> f"""Final result: [bold green]"{res.path[-1].result.value}"[\bold green]\n'"""
<add> )
|
# module: ciphey.iface._modules
def pretty_search_results(res: SearchResult, display_intermediate: bool = False):
<0> ret: str = f'Final result: "{res.path[-1].result.value}"\n'
<1> if len(res.check_res) != 0:
<2> ret += f"Checker: {res.check_res}\n"
<3> ret += "Format used:\n"
<4>
<5> def add_one():
<6> nonlocal ret
<7> ret += f" {i.name}"
<8> already_broken = False
<9> if i.result.key_info is not None:
<10> ret += f":\n Key: {i.result.key_info}\n"
<11> already_broken = True
<12> if i.result.misc_info is not None:
<13> if not already_broken:
<14> ret += ":\n"
<15> ret += f" Misc: {i.result.misc_info}\n"
<16> already_broken = True
<17> if display_intermediate:
<18> if not already_broken:
<19> ret += ":\n"
<20> ret += f' Value: "{i.result.value}"\n'
<21> already_broken = True
<22> if not already_broken:
<23> ret += "\n"
<24>
<25> # Skip the 'input' and print in reverse order
<26> for i in res.path[1:][::-1]:
<27> add_one()
<28>
<29> # Remove trailing newline
<30> return ret[:-1]
<31>
|
===========unchanged ref 0===========
at: ciphey.iface._modules
SearchResult(typename: str, fields: Iterable[Tuple[str, Any]]=..., **kwargs: Any)
at: ciphey.iface._modules.CrackResult
value: T
key_info: Optional[str] = None
misc_info: Optional[str] = None
at: ciphey.iface._modules.SearchLevel
name: str
result: CrackResult
at: ciphey.iface._modules.SearchResult
path: List[SearchLevel]
check_res: str
===========changed ref 0===========
# module: ciphey
+ if __name__ == '__main__':
+ __main__.main()
-
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.