Spaces:
Sleeping
Sleeping
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) | |