2021-10-17 21:38:16 +00:00
|
|
|
"""
|
|
|
|
!/usr/bin/env python
|
|
|
|
|
|
|
|
https://pypi.org/project/websockets/
|
|
|
|
|
|
|
|
@author Lachezar Todorov
|
|
|
|
"""
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import encrypt_decrypt
|
|
|
|
from websockets import serve
|
|
|
|
|
|
|
|
class Bob():
|
2021-10-17 22:15:12 +00:00
|
|
|
def __init__(self,privateKey):
|
|
|
|
self.pk = privateKey
|
|
|
|
|
|
|
|
async def decrypt(websocket, path):
|
|
|
|
privateKey = "" #dummy variable to make code work, please change!
|
2021-10-17 21:38:16 +00:00
|
|
|
async for message in websocket:
|
|
|
|
message = await websocket.recv()
|
|
|
|
decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey)
|
2021-10-17 22:15:12 +00:00
|
|
|
#await websocket.send(decryptedMessage)
|
|
|
|
print(decryptedMessage)
|
2021-10-17 21:38:16 +00:00
|
|
|
|
2021-10-17 22:15:12 +00:00
|
|
|
async def messageDecrypt(privateKey):
|
|
|
|
#do something with privateKey to send it to decrypt
|
|
|
|
|
|
|
|
async with serve(Bob.decrypt, "localhost", 8765):
|
2021-10-17 21:38:16 +00:00
|
|
|
await asyncio.Future() # run forever
|
|
|
|
|
2021-10-17 08:16:54 +00:00
|
|
|
#asyncio.run(main())
|