Onionr/onionr/onionrutils/bytesconverter.py

15 lines
303 B
Python
Raw Permalink Normal View History

def str_to_bytes(data):
2019-06-26 20:13:36 +00:00
'''Converts a string to bytes with .encode()'''
try:
2019-06-26 20:13:36 +00:00
data = data.encode('UTF-8')
except AttributeError:
pass
return data
def bytes_to_str(data):
try:
2019-06-26 20:13:36 +00:00
data = data.decode('UTF-8')
except AttributeError:
pass
2019-08-09 20:41:27 +00:00
return data