From b9cf6dc6b5a04f5c6eda23ce90f21a3e429ac962 Mon Sep 17 00:00:00 2001 From: Lachezar Todorov Date: Sun, 17 Oct 2021 17:38:16 -0400 Subject: [PATCH] Made Alice and Bob classes. Alice encrypts a message and sends it to Bob, who decrypts the message and should print the plaintext to show he decrypted it. However, that is not the case. --- .gitignore | 0 LICENSE | 0 README.md | 0 src/py-cli/encrypt_decrypt.py | 0 src/py-cli/main.py | 0 src/py-cli/websock/alice.py | 42 ++++++++++++++++---------------- src/py-cli/websock/bob.py | 46 +++++++++++++++++------------------ 7 files changed, 44 insertions(+), 44 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 src/py-cli/encrypt_decrypt.py mode change 100644 => 100755 src/py-cli/main.py mode change 100644 => 100755 src/py-cli/websock/alice.py mode change 100644 => 100755 src/py-cli/websock/bob.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/src/py-cli/encrypt_decrypt.py b/src/py-cli/encrypt_decrypt.py old mode 100644 new mode 100755 diff --git a/src/py-cli/main.py b/src/py-cli/main.py old mode 100644 new mode 100755 diff --git a/src/py-cli/websock/alice.py b/src/py-cli/websock/alice.py old mode 100644 new mode 100755 index 49c6a42..6704e39 --- a/src/py-cli/websock/alice.py +++ b/src/py-cli/websock/alice.py @@ -1,22 +1,22 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt - -from websockets import connect - -class Alice(): - async def messageEncrypt(uri, publicKey, message): - encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) - async with connect(uri) as websocket: - await websocket.send(encryptedMessage) - message = await websocket.recv() - print(message) - +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt + +from websockets import connect + +class Alice(): + async def messageEncrypt(uri, publicKey, message): + encryptedMessage = encrypt_decrypt.encrypt_decrypt.encryption(message, publicKey) + async with connect(uri) as websocket: + await websocket.send(encryptedMessage) + message = await websocket.recv() + print(message) + #asyncio.run(hello("ws://localhost:8765")) \ No newline at end of file diff --git a/src/py-cli/websock/bob.py b/src/py-cli/websock/bob.py old mode 100644 new mode 100755 index 81a2563..9cf6b87 --- a/src/py-cli/websock/bob.py +++ b/src/py-cli/websock/bob.py @@ -1,24 +1,24 @@ -""" -!/usr/bin/env python - -https://pypi.org/project/websockets/ - -@author Lachezar Todorov -""" - -import asyncio -import encrypt_decrypt -from websockets import serve - -class Bob(): - async def decrypt(websocket, path, privateKey): - async for message in websocket: - message = await websocket.recv() - decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) - await websocket.send(decryptedMessage) - - async def main(privateKey): - async with serve(Bob.decrypt, "localhost", 8765, privateKey): - await asyncio.Future() # run forever - +""" +!/usr/bin/env python + +https://pypi.org/project/websockets/ + +@author Lachezar Todorov +""" + +import asyncio +import encrypt_decrypt +from websockets import serve + +class Bob(): + async def decrypt(websocket, path, privateKey): + async for message in websocket: + message = await websocket.recv() + decryptedMessage = encrypt_decrypt.encrypt_decrypt.decryption(message, privateKey) + await websocket.send(decryptedMessage) + + async def main(privateKey): + async with serve(Bob.decrypt, "localhost", 8765, privateKey): + await asyncio.Future() # run forever + #asyncio.run(main()) \ No newline at end of file