Nov-27-2023, 12:30 PM
The method
The
Try this.
text_to_numeric_binary_blocks
,this padding might not be correctly handled during decryption.The
ljust
method pads with zeros,which can alter the actual value of the data when converted back.Try this.
def text_to_numeric_binary_blocks(self, text, block_size=10): text = text.encode() binary_blocks = [ ''.join(format(byte, '08b') for byte in text[i:i + block_size]) for i in range(0, len(text), block_size) ] return binary_blocks