You can generate 9 bytes and take the first 66 bits using a bitmask operation. on the last byte.
Here's a beautiful one liner:
"".join([bin(c).replace("0b", "").zfill(8) for c in us.urandom(9)])[:-6]
This will generate 9 bytes of random as a byte string, them iterate the 9 bytes in the byte string, convert each one into a binary string notation (i.e. 0b110001, remove the 0b from the front, zero pad where needed, join into a single string and strip the excess 6 bits from the end.
convert ever
I am writing an experimental code that generates random tokens using os.urandom, I was wondering how do I generate a 66 bit random token.? 66 bit is 8.25 bytes and it does not take floating numbers. I specifically need 66 bit how do i do it?
how do i use bits insted of bytes in (os.urandom(32)