for python:
def sid_to_bytes(sid: str) -> bytes:
sid = sid.replace('S-', '')
sid = sid.split('-')
c = int_to_bytes(int(sid[0]), 1)
c += int_to_bytes(len(sid) - 2, 1)
for i in range(0, 5):
c += int_to_bytes(0, 1)
c += int_to_bytes(int(sid[1]), 1)
for i in range(2, len(sid)):
c += int_to_bytes(int(sid[i]), 4)
return c
Article how to do it: https://sergeyvasin.wordpress.com/2017/09/06/convertfrom-sthsid/