initial commit
This commit is contained in:
commit
aebe21e224
34
client_test_1.py
Normal file
34
client_test_1.py
Normal file
@ -0,0 +1,34 @@
|
||||
import socket
|
||||
import sys
|
||||
|
||||
# Create a TCP/IP socket
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
# Connect the socket to the port where the server is listening
|
||||
server_address = ('localhost', 15555)
|
||||
print('connecting to {} port {}'.format(*server_address))
|
||||
sock.connect(server_address)
|
||||
|
||||
try:
|
||||
|
||||
# Send data
|
||||
message = b'This is the message. It will be repeated.'
|
||||
print('sending {!r}'.format(message))
|
||||
sock.sendall(message)
|
||||
quit_msg_code = b'|<--eos-->|'
|
||||
|
||||
# Look for the response
|
||||
amount_received = 0
|
||||
amount_expected = len(message)
|
||||
|
||||
while amount_received < amount_expected:
|
||||
#while 1:
|
||||
data = sock.recv(16)
|
||||
amount_received += len(data)
|
||||
print('received {!r}'.format(data))
|
||||
print('will send \'eos\' signal')
|
||||
sock.sendall(quit_msg_code)
|
||||
|
||||
finally:
|
||||
print('closing socket')
|
||||
sock.close()
|
||||
BIN
crypto_v1.zip
Normal file
BIN
crypto_v1.zip
Normal file
Binary file not shown.
1
decrypted_file.txt
Normal file
1
decrypted_file.txt
Normal file
@ -0,0 +1 @@
|
||||
test content
|
||||
BIN
encrypted_file.data
Normal file
BIN
encrypted_file.data
Normal file
Binary file not shown.
1
not_encrypted_file.txt
Normal file
1
not_encrypted_file.txt
Normal file
@ -0,0 +1 @@
|
||||
test content
|
||||
15
private_key.key
Normal file
15
private_key.key
Normal file
@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXQIBAAKBgQC1Y8c78PzupR80AyXRye8UHFGJkYjhCh+eGBhx8zuB8bnIdopl
|
||||
BV+UoLouRjQILnXxhSIsDeGvrd9A5hlX2qMz9G5QTw0ie4FstSvO7VSFnph60jnl
|
||||
rNZ4SUeuC/G6bVGhp1+Rr910Y8NP6TqQBH4X5czHxbBWAS//qAdo2miBvQIDAQAB
|
||||
AoGAQFP0clOSv+ebW0zKes4Mlas9V3Zffr+iWuTctny2W+0oH+m6Rv1S2ljt7j9D
|
||||
cKtZdJ/scIczxKP7Cv8PedK2EbsHPJAWLsVpVtSRgd7Wzmt18tSoy+J6vAqiG4Th
|
||||
e4QUqLYywJK1/XkHgCeI2RfSd6EcHVezEq71FXww+UEqJJkCQQDxZlM1DYM6E6Xz
|
||||
dwhxensfaLcdzn0uhHdSF/ljsyVkrt2qLeay5bGcJKloVEQ7kuYNQdLZrpwaiPWn
|
||||
WKo7r87LAkEAwFxMaelt6jbmNxhuGWsWsq/AEDJkEtVmynzZkStCHv5PSqHU3xFx
|
||||
2w+JU1q8IDPrNAhMF9FphDqmrncKBieYlwJADo2bsJQa+DJdC9t+P9EhgRhACeT7
|
||||
+QT1aJaXa2JOe85rAKp5wQlF9uLi76482taVVfFE8+ip8pOVM7yNrsF/lwJBAK4u
|
||||
5cLB7RW4wJ4DMS8zGUqUeoYwGw4yzvFsPFaHpUgLYCFkiS20zjRezSr9bnx6hvCG
|
||||
0uB+b92cfnJcuGb6U+ECQQCiruKFB+988pcpjk5rd47RScpncKaY/kBeGRPjy4W/
|
||||
7kAAROOrq5WBy4LlVOIkUrv05TeKJmeuEw3x9hC3JYPs
|
||||
-----END RSA PRIVATE KEY-----
|
||||
6
public_key.pub
Normal file
6
public_key.pub
Normal file
@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1Y8c78PzupR80AyXRye8UHFGJ
|
||||
kYjhCh+eGBhx8zuB8bnIdoplBV+UoLouRjQILnXxhSIsDeGvrd9A5hlX2qMz9G5Q
|
||||
Tw0ie4FstSvO7VSFnph60jnlrNZ4SUeuC/G6bVGhp1+Rr910Y8NP6TqQBH4X5czH
|
||||
xbBWAS//qAdo2miBvQIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
24
server_test_1.py
Normal file
24
server_test_1.py
Normal file
@ -0,0 +1,24 @@
|
||||
import asyncio, socket
|
||||
|
||||
async def handle_client(reader, writer):
|
||||
request = None
|
||||
quit_msg_code = b'|<--eos-->|'
|
||||
while request != quit_msg_code:
|
||||
print('Receiving ans [ ... ]')
|
||||
request = (await reader.read(255)).decode('utf8')
|
||||
print('Receiving ans [ OK ] {}'.format(request))
|
||||
response = str(request) + '\n'
|
||||
writer.write(response.encode('utf8'))
|
||||
try:
|
||||
await writer.drain()
|
||||
# Prevent closed connections without 'eos'
|
||||
except ConnectionResetError:
|
||||
print('Connection Closed')
|
||||
break
|
||||
print('Received \'eos\' signal, will now close session [ ... ]')
|
||||
writer.close()
|
||||
print('Session closed [ OK ]')
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(asyncio.start_server(handle_client, 'localhost', 15555))
|
||||
loop.run_forever()
|
||||
Loading…
Reference in New Issue
Block a user