samedi 24 août 2019

Decode /dev/urandom bytes in Python + basic on encoding

I'm having fun in python with generating random bytes like this:

with open('/dev/urandom', 'rb') as f:
    randbytes = f.read(10)

but, to decoding, I don't know if i need to use utf-8, utf-16, base64 or others encoding. I already tried the listed above and no one work, except utf-16 but sometimes fail raising UnicodeDecodeError.

Moreover, I don't know precisely what's an encoding is, so can anyone explain the basic of encoding strings and decoding bytes in python? Thanks.




Aucun commentaire:

Enregistrer un commentaire