mirror of
https://github.com/SantaSpeen/winConnect.git
synced 2026-02-16 02:20:58 +00:00
Add examples with crypto
This commit is contained in:
27
examples/with_crypto/client_simple.py
Normal file
27
examples/with_crypto/client_simple.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from winConnect import WinConnectClient, crypto
|
||||
|
||||
logger.remove()
|
||||
logger.add(sys.stdout, level="DEBUG")
|
||||
|
||||
crypt_mode = crypto.WinConnectCryptoSimple()
|
||||
|
||||
connector = WinConnectClient('test')
|
||||
connector.set_logger(logger)
|
||||
connector.set_crypto(crypt_mode)
|
||||
|
||||
def console():
|
||||
with connector as conn:
|
||||
while True:
|
||||
i = input(":> ")
|
||||
if i == "exit":
|
||||
break
|
||||
conn.send_data(i)
|
||||
data = conn.read_pipe()
|
||||
print(f"({type(data)}) {data=}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
console()
|
||||
21
examples/with_crypto/server_simple.py
Normal file
21
examples/with_crypto/server_simple.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import sys
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from winConnect import WinConnectDaemon
|
||||
from winConnect import crypto
|
||||
|
||||
logger.remove()
|
||||
logger.add(sys.stdout, level="DEBUG")
|
||||
|
||||
crypt_mode = crypto.WinConnectCryptoSimple()
|
||||
|
||||
connector = WinConnectDaemon('test')
|
||||
connector.set_logger(logger)
|
||||
connector.set_crypto(crypt_mode)
|
||||
|
||||
for data in connector.listen():
|
||||
print(f"({type(data)}) {data=}")
|
||||
if data is None and connector.closed:
|
||||
break
|
||||
connector.send_data(data)
|
||||
Reference in New Issue
Block a user