Created
January 6, 2022 07:17
-
-
Save crowjdh/ea9106ae239e86faac5eded3d44e695a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bytes_to_bits(bytes): | |
bits_repr = bin(int(bytes, base=16))[2:] | |
bits = [] | |
for end_idx in range(len(bits_repr) - 1, 0 - 1, -4): | |
end_idx = end_idx + 1 | |
start_idx = max(0, end_idx - 4) | |
bits_chunk = bits_repr[start_idx:end_idx] | |
bits.append(bits_chunk) | |
return list(reversed(bits)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment