mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 18:54:08 +00:00
Add optional kasa-crypt dependency for speedups (#464)
If installed, use the optimized protocol encryption procedures implemented as a C extension by kasa-crypt (https://pypi.org/project/kasa-crypt/
This commit is contained in:
@@ -219,3 +219,13 @@ class TPLinkSmartHomeProtocol:
|
||||
return bytes(
|
||||
TPLinkSmartHomeProtocol._xor_encrypted_payload(ciphertext)
|
||||
).decode()
|
||||
|
||||
|
||||
# Try to load the kasa_crypt module and if it is available
|
||||
try:
|
||||
from kasa_crypt import decrypt, encrypt
|
||||
|
||||
TPLinkSmartHomeProtocol.decrypt = decrypt # type: ignore[method-assign]
|
||||
TPLinkSmartHomeProtocol.encrypt = encrypt # type: ignore[method-assign]
|
||||
except ImportError:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user