Skip to content

Instantly share code, notes, and snippets.

@D3f0
Created July 2, 2018 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D3f0/5955d435637ff31a6cbcaaf7635e73f2 to your computer and use it in GitHub Desktop.
Save D3f0/5955d435637ff31a6cbcaaf7635e73f2 to your computer and use it in GitHub Desktop.
Binary IP check
# Checks that binary representation is the same as int.from_bytes(..., 'big')
bin(int.from_bytes(ip_address('200.1.17.25').packed, 'big'))[2:] == ''.join(format(i, '08b') for i in map(int, '200.1.17.25'.split('.')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment