I know something similar has been asked before, but no answer has yet worked.
I make a byte string:
salt = os.urandom(16)
which gives something like:
b'w\x05\xce^f\xdcbM\xe9\xb8c\x8b\x98\xd2\n\x11'
What I need is to give this to the user, so they can copy and paste, place it in a text document or anywhere, and then paste it back in the terminal later.
In short. I need to convert it to a string. And then back to its encoding.
I have tried salt.decode(encoding="utf-8") and many variations which all give me some form of UnicodeDecodeError: 'utf-8' codec can't..., The only one that seemed to work was "".join(map(chr, salt)), but I can't figure out how to reverse this.
Thanks in advance. P.s. I am working in Python 3