I tried to generate random string with
python3 -c 'import base64, os; print(base64.b64encode(os.urandom(24)))'
The output is:
b'32randomstring'
Is it possible to remove the b'' ?
I tried to generate random string with
python3 -c 'import base64, os; print(base64.b64encode(os.urandom(24)))'
The output is:
b'32randomstring'
Is it possible to remove the b'' ?
The b
-prefix indicates that you are dealing with a byte string, which is basically just a sequence of bytes. to turn those into text, you need to apply some encoding.
Given that you used base64, all the produced bytes nicely map onto ascii anyway, and you can do something like this:
print(base64.b64encode(os.urandom(24)).decode("ascii"))