allan icon

Checkpoint Log IP-Hex Converter

allan | PRO | 09/28/22 07:57:43 PM UTC (Edited) | 0 ⭐ | 1010 👁️ | Never ⏰ | []
Python |

680 B

|

Source Code

|

0 👍

/

0 👎

# for pasting into a firewall's Python3 IDLE - no error checking.
# make sure to use the raw version of this paste!
 
def ip_hex():
 txt = input('IP: ')
 while txt != '':
  ip_int = [ int(oct) for oct in txt.split('.') ]
  ip_hex = list(map(lambda n:'%02x' % n, ip_int))
  out_str = ''.join(ip_hex)
  if out_str[0] == '0':
   out_str = out_str[1:]
  print(out_str)
  txt = input('IP: ')
 
def hex_ip():
 txt = input('hex: ')
 while txt != '':
  if txt[0:2] == '0x':
   txt = txt[2:]
  if (len(txt) % 2) == 1:
   txt = '0' + txt
  oct = list()
  for pos in range(0, len(txt), 2):
   oct.append(str(int(txt[pos:pos + 2], 16)))
  print('.'.join(oct))
  txt = input('hex: ')
 
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎