59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
# https://realpython.com/python-sockets/
|
|
# echo-client.py
|
|
import socket
|
|
|
|
from dsa import ver_DSA
|
|
|
|
byteorder = "big"
|
|
HOST = "150.254.79.244"
|
|
PORT = 65432 # The port used by the server
|
|
|
|
print()
|
|
print("-"*200)
|
|
print("tu sie zaczyna program klient.py")
|
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as socket1:
|
|
socket1.connect((HOST, PORT))
|
|
|
|
hello = socket1.recv(1024)
|
|
print(hello)
|
|
|
|
p_len = socket1.recv(1024)
|
|
q_len = socket1.recv(1024)
|
|
g_len = socket1.recv(1024)
|
|
y_len = socket1.recv(1024)
|
|
|
|
print(int.from_bytes(p_len, byteorder),int.from_bytes(q_len, byteorder),int.from_bytes(g_len, byteorder),int.from_bytes(y_len, byteorder))
|
|
|
|
p = socket1.recv(int.from_bytes(p_len, byteorder))
|
|
q = socket1.recv(int.from_bytes(q_len, byteorder))
|
|
g = socket1.recv(int.from_bytes(g_len, byteorder))
|
|
y = socket1.recv(int.from_bytes(y_len, byteorder))
|
|
|
|
int_p = int.from_bytes(p, byteorder)
|
|
int_q = int.from_bytes(q, byteorder)
|
|
int_g = int.from_bytes(g, byteorder)
|
|
int_y = int.from_bytes(y, byteorder)
|
|
|
|
print(int_p,int_q,int_g,int_y)
|
|
|
|
do_podpisania = b"Hello, world"
|
|
socket1.sendall(do_podpisania)
|
|
|
|
r_len = socket1.recv(1024)
|
|
s_len = socket1.recv(1024)
|
|
|
|
print(int.from_bytes(r_len, byteorder), int.from_bytes(s_len, byteorder))
|
|
|
|
r = socket1.recv(int.from_bytes(r_len, byteorder))
|
|
s = socket1.recv(int.from_bytes(s_len, byteorder))
|
|
|
|
int_r = int.from_bytes(r, byteorder)
|
|
int_s = int.from_bytes(s, byteorder)
|
|
|
|
print(int_r,int_s)
|
|
|
|
m = do_podpisania
|
|
weryfikacja_DSA = ver_DSA(int_p, int_q, int_g, int_y, m, int_r,int_s)
|
|
print(weryfikacja_DSA)
|