onionr/onionr/onionrutils/bytesconverter.py

14 lines
302 B
Python
Raw 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
return data