Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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: ')
Advertisement