-
Notifications
You must be signed in to change notification settings - Fork 0
/
cursor.py
36 lines (27 loc) · 1.15 KB
/
cursor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import time
import subprocess
import os
ascii_output = ""
pause = 1
def clear_screen():
if os.name == 'posix': # Unix-like OS
subprocess.call('clear', shell=True)
elif os.name == 'nt': # Windows
subprocess.call('cls', shell=True)
# Binary string to be converted
binary_string = "0110111001100101011101100110010101110010001000000110011101101111011011100110111001100001001000000110011101101001011101100110010100100000011110010110111101110101001000000111010101110000"
# Loop over the binary string in chunks of 8 bits (1 byte)
for i in range(0, len(binary_string), 8):
byte = binary_string[i:i+8]
clear_screen()
cursor_position = " " * i + "^" # Adjust the cursor position based on current index
print(f"Binary String:\n{binary_string}\n{cursor_position}")
print(f"Processing byte: {byte}") # Extract 8 bits
# binary byte to a decimal value
decimal_value = int(byte, 2)
print(f"Decimal value: {decimal_value}")
# decimal value to the corresponding ASCII character
ascii_char = chr(decimal_value)
time.sleep(pause)
print(f"ASCII character: {ascii_char}")
time.sleep(pause)