Given the IP address in four-point notation with periods, for example:
192.192.45.1
And the length of the mask, for example, 8, 16, 24, as a rule, but can be any, i.e. 17.
Can someone request code in python to calculate subnet mask? Preferably, I can obtain the result as a 32-bit integer, so that it is easily hashed and then reinterpreted as a dotted square when necessary for printing. I see that python has a socket library, which is basically a wrapper around the unix api socket. I also saw that it has an inet_ntoa () function, but it returns some kind of package structure. I am not very familiar with the Python structure library, so I was hoping someone would have some ideas. Thanks!
source share