Onionr/onionr/onionrutils/bytesconverter.py
2019-08-09 15:41:27 -05:00

15 lines
303 B
Python

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