[text] cccccccccccccccc

Viewer

copydownloadembedprintName: cccccccccccccccc
  1. import socket
  2.  
  3. def main():
  4.     # Server configuration
  5.     host = '127.0.0.1'
  6.     port = 12345
  7.  
  8.     # Create a socket object
  9.     server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  10.  
  11.     # Bind the socket to the address
  12.     server_socket.bind((host, port))
  13.  
  14.     # Listen for incoming connections
  15.     server_socket.listen(1)
  16.     print("Server is listening on port", port)
  17.  
  18.     # Accept a connection
  19.     client_socket, addr = server_socket.accept()
  20.     print("Connection from", addr)
  21.  
  22.     # Receive data from the client
  23.     data = client_socket.recv(1024).decode()
  24.     print("Received data from server:", data)
  25.  
  26.     # Split received data into individual values
  27.     values = data.split(',')
  28.  
  29.     # Display received values
  30.     print("Received values from server:")
  31.     print("p:", values[0])
  32.     print("q:", values[1])
  33.     print("g:", values[2])
  34.     print("k:", values[3])
  35.     print("hm:", values[4])
  36.     print("x:", values[5])
  37.     print("y:", values[6])
  38.     print("s:", values[8])
  39.     print("\n")
  40.     print("Verification:")
  41.     print("w:", values[9])
  42.     print("u1:", values[10])
  43.     print("u2:", values[11])
  44.     print("v:", values[12])
  45.     print("\n")
  46.     print("r' (from sender):", values[7])
  47.     print("v  (calculated):", values[12])
  48.  
  49.     # Perform DSS verification
  50.     r = int(values[7])
  51.     v = int(values[12])
  52.     if v == r:
  53.         print("Digital Signature Standard (DSS) verification Successful")
  54.     else:
  55.         print("Digital Signature Standard (DSS) Verification Failed")
  56.  
  57.     # Close the connection
  58.     client_socket.close()
  59.  
  60. if __name__ == "__main__":
  61.     main()

Editor

You can edit this paste and save as new:


File Description
  • cccccccccccccccc
  • Paste Code
  • 16 Apr-2024
  • 1.61 Kb
You can Share it: