Skip to content

Commit

Permalink
fix: adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Jun 16, 2023
1 parent 9b745de commit 6c66d4c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/kasa_crypt/python_impl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def encrypt_pure_python(string: str) -> bytearray:
"""Encrypt."""
unencrypted = string.encode()
key = 171
unencrypted_len = len(unencrypted)
encrypted = bytearray(unencrypted_len)
for idx, unencryptedbyte in enumerate(unencrypted):
key = key ^ unencryptedbyte
encrypted[idx] = key
return encrypted


def decrypt_pure_python(string: bytes) -> str:
"""Decrypt."""
key = 171
result = bytearray(len(string))
for idx, i in enumerate(string):
a = key ^ i
key = i
result[idx] = a
return result.decode()

0 comments on commit 6c66d4c

Please sign in to comment.