MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / decode_base64_to_text

Function decode_base64_to_text

backend/tkhelper/utils/base_64.py:29–48  ·  view source on GitHub ↗

Decodes a Base64 encoded string back into a normal string. :param base64_string: str - The Base64 encoded string to be decoded. :return: str - The decoded string.

(base64_string)

Source from the content-addressed store, hash-verified

27
28
29def decode_base64_to_text(base64_string):
30 """
31 Decodes a Base64 encoded string back into a normal string.
32
33 :param base64_string: str - The Base64 encoded string to be decoded.
34 :return: str - The decoded string.
35 """
36
37 # Add padding characters to the base64 string if necessary
38 padding = "=" * (-len(base64_string) % 4)
39 base64_string_with_padding = base64_string + padding
40
41 # Encode these bytes and then decode the result to get a string
42 base64_bytes = base64_string_with_padding.encode("utf-8")
43
44 # Decode the base64 bytes and then decode the result to get a string
45 input_bytes = base64.b64decode(base64_bytes)
46 input_string = input_bytes.decode("utf-8")
47
48 return input_string

Callers 1

get_file_metadataMethod · 0.90

Calls 2

encodeMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected