0
encoded_str = "AGgAZQBsAGwAb8VIsVUwSjBvMIg="
bin_encoded_str = 0000000001101000000000000110010100000000011011000000000001101100000000000110111111000101010010001011000101010101001100000100101000110000011011110011000010001000
for i in range(int(len(bin_encoded_str)/16)):
decode_str = decode_str + chr("{0:b}".bin_encoded_str[i*16:(i+1)*16])

AttributeError: 'str' object has no attribute 'bin_encoded_str'

I was trying to make a base64 decoder.

Character encoding is using utf-16be.

I want to complete the corresponding Unicode character through the binary string.

 decode_str = decode_str + chr(int(bin_encoded_str[i*16:(i+1)*16]))

OverflowError: Python int too large to convert to C int

If you try to change to int type, it overflowed and blocked

Is there a way to solve this?

thanks

3
  • What is the expected output? Are you looking for using the second argument of the int function: int(....., 2)? Commented Sep 17, 2022 at 17:59
  • Finally, we want to get "hello안녕おはよ "strings, and first we want to change the binary string to binary numbers so that we can get those characters. Commented Sep 17, 2022 at 18:03
  • 1
    int(..., 2) I was able to get the result I wanted Thank you. Commented Sep 17, 2022 at 18:04

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.