File size: 287 Bytes
fb28dd9
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
def binary_to_text(binary_data):
    try:
        n = int(binary_data, 2)
        return n.to_bytes((n.bit_length() + 7) // 8, 'big').decode()
    except Exception:
        return "Invalid binary input"

def text_to_binary(text):
    return ' '.join(format(ord(c), '08b') for c in text)