Skip to content

Commit

Permalink
🗓 Nov 5, 2024 12:38:36 AM
Browse files Browse the repository at this point in the history
🔧 fix decimal xor
  • Loading branch information
securisec committed Nov 5, 2024
1 parent 3b245ea commit 1d66bac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion chepy/chepy_plugins
Submodule chepy_plugins updated 1 files
+2 −2 docs/conf.py
17 changes: 11 additions & 6 deletions chepy/modules/encryptionencoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,18 @@ def xor(
elif key_type == "base64":
key = binascii.hexlify(base64.b64decode(key.encode()))
elif key_type == "decimal":
key = binascii.hexlify(
int(key).to_bytes(len(str(key)), byteorder="big")
)
if int(key) < 0 or int(key) > 255:
raise ValueError("Invalid decimal key") # pragma: no cover

key = binascii.unhexlify(key)
for char, key_val in zip(self._convert_to_bytes(), itertools.cycle(key)):
x.append(char ^ key_val)
_s = self._convert_to_bytes()

if key_type == "decimal":
for b in _s:
x.append(b ^ int(key))
else:
key = binascii.unhexlify(key)
for char, key_val in zip(_s, itertools.cycle(key)):
x.append(char ^ key_val)

self.state = bytes(x)
return self
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def setup(app):
# -- Project information -----------------------------------------------------

project = "Chepy"
copyright = "2019, Hapsida @securisec"
author = "Hapsida @securisec"
copyright = "2019, @securisec"
author = "@securisec"

master_doc = 'index'

Expand Down

0 comments on commit 1d66bac

Please sign in to comment.