Created
August 28, 2020 23:11
-
-
Save AIT-RAMI/c90a851022603573ea3d25f3bcb8a668 to your computer and use it in GitHub Desktop.
uudecoder
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
input_string = input("String to uudeocode: (You may want to remove the first character)\n") | |
def binary(num, pre='', length=8, spacer=0): | |
return '{0}{{:{1}>{2}}}'.format(pre, spacer, length).format(bin(num)[2:]) | |
binary_output = "" | |
for c in input_string: | |
binary_output += binary(ord(c) - 32)[2:] | |
ouput_string = "" | |
for i in range(0, len(binary_output), 8): | |
ouput_string += chr(int(binary_output[i:i+8], 2)) | |
print(ouput_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment