import binascii
def text2int(msg):
    print(msg)
    
    # Konwersja string na hex
    # hexstr = msg.encode("utf-8").hex()
    msg = msg.encode()
    hexstr = binascii.hexlify(msg)
    print(hexstr)
    
    # Konwersja hex na int
    integer_m = int(hexstr, 16)
    print(integer_m)
    
    # Ponowna konwersja int na hex
    back2hex = format(integer_m, 'x')
    print(back2hex)
    
    # Ponowna konwersja na string
    evenpad = ('0' * (len(back2hex) % 2)) + back2hex
    # import codecs
    # plaintext = codecs.decode(evenpad, 'hex')
    plaintext = binascii.unhexlify(evenpad)
    
    print(plaintext)

text2int("Witaj")
