Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NETBIOS encode/decode
# Implemented the reverse of the compact answer on:
# https://stackoverflow.com/questions/1965065/encode-netbios-name-python/1965140
def netbios_encode(input_string):
return ''.join([chr((ord(c)>>4)+ord('A'))+chr((ord(c)&0xF)+ord('A')) for c in input_string])
def netbios_decode(netbios):
i = iter(netbios.upper())
try:
return ''.join([chr(((ord(c)-ord('A'))<<4)+((ord(next(i))-ord('A'))&0xF)) for c in i])
except:
return ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.