I am working on implementation of a secure communication protocol between a client C and a server S using Python. For the purpose of making the communication secure (i.e. the messages transferred between C and S are confidential, authenticated and integrity is maintained), I need IDs of both C and S for making it possible.
I tried the following:
import socket
import sys
import hashlib
def server_register():
name = gethostname()
hostid = socket.gethostbyaddr(name)
However, this gives me the hostid = 127.0.1.1
which is the IP address of the local host. Also, as the IP addresses are dynamic in nature, I think it is not appropriate to use them as the ID for either of the devices.
How can I get the IDs of the client and the server in Python (considering that the IDs will remain constant/fixed throughout the communication?