Module src.onionrutils.bytesconverter

Expand source code
def str_to_bytes(data):
    '''Converts a string to bytes with .encode()'''
    try:
        data = data.encode('UTF-8')
    except AttributeError:
        pass
    return data

def bytes_to_str(data):
    try:
        data = data.decode('UTF-8')
    except AttributeError:
        pass
    return data

Functions

def bytes_to_str(data)
Expand source code
def bytes_to_str(data):
    try:
        data = data.decode('UTF-8')
    except AttributeError:
        pass
    return data
def str_to_bytes(data)

Converts a string to bytes with .encode()

Expand source code
def str_to_bytes(data):
    '''Converts a string to bytes with .encode()'''
    try:
        data = data.encode('UTF-8')
    except AttributeError:
        pass
    return data