Skip to content

Instantly share code, notes, and snippets.

@AIT-RAMI
Created August 28, 2020 23:11
Show Gist options
  • Save AIT-RAMI/c90a851022603573ea3d25f3bcb8a668 to your computer and use it in GitHub Desktop.
Save AIT-RAMI/c90a851022603573ea3d25f3bcb8a668 to your computer and use it in GitHub Desktop.
uudecoder
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