I want to concatenate the output bytes from /dev/random to a string that I am generating in my program. But this is giving me errors :
'ascii' codec can't decode byte 0xd9 in position 2: ordinal not in range(128)
So i converted the dev/random output to unicode
unicode(s, errors='ignore')
But this again fails if the output from /dev/random happens to a large number (long) since that wont match to a unicode value. As of now i am reading 42 bytes from dev/random using
open("/dev/random","rb").read(42)
But this can be any number of bytes. What is a safe way to concatenate these values so that the program does not fail for any values.
Aucun commentaire:
Enregistrer un commentaire