-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
__version__ = "0.0.0" | ||
|
||
from .kasa_crypt import decrypt, encrypt | ||
|
||
__all__ = ["encrypt", "decrypt"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import json | ||
|
||
from kasa_crypt import decrypt, encrypt | ||
|
||
# from | ||
# https://github.com/python-kasa/python-kasa/blob/master/kasa/tests/test_protocol.py | ||
|
||
|
||
def test_encrypt(): | ||
d = json.dumps({"foo": 1, "bar": 2}) | ||
encrypted = encrypt(d) | ||
# encrypt adds a 4 byte header | ||
encrypted = encrypted[4:] | ||
assert d == decrypt(encrypted) | ||
|
||
|
||
def test_encrypt_unicode(): | ||
d = "{'snowman': '\u2603'}" | ||
|
||
e = bytes( | ||
[ | ||
208, | ||
247, | ||
132, | ||
234, | ||
133, | ||
242, | ||
159, | ||
254, | ||
144, | ||
183, | ||
141, | ||
173, | ||
138, | ||
104, | ||
240, | ||
115, | ||
84, | ||
41, | ||
] | ||
) | ||
|
||
encrypted = encrypt(d) | ||
# encrypt adds a 4 byte header | ||
encrypted = encrypted[4:] | ||
|
||
assert e == encrypted | ||
|
||
|
||
def test_decrypt_unicode(): | ||
e = bytes( | ||
[ | ||
208, | ||
247, | ||
132, | ||
234, | ||
133, | ||
242, | ||
159, | ||
254, | ||
144, | ||
183, | ||
141, | ||
173, | ||
138, | ||
104, | ||
240, | ||
115, | ||
84, | ||
41, | ||
] | ||
) | ||
|
||
d = "{'snowman': '\u2603'}" | ||
|
||
assert d == decrypt(e) |
This file was deleted.
Oops, something went wrong.