import base64 from pydantic import BaseModel, ValidationError def find_base64_truncation(encoded_data): # 将输入字符串划分为4字符的组 for i in range(0, len(encoded_data), 4): chunk = encoded_data[i:i+4] try: # 尝试解码当前4字符组 res = base64.b64decode(chunk) print(f"解码成功,截断点位于索引 {i}, 字符组为 '{chunk}', 解码结果为: {res.decode()}") except Exception as e: # 如果解码失败,打印出错误位置和可能的截断点 print(f"可能的截断点位于索引 {i}, 字符组为 '{chunk}', 错误信息: {e}") break # 假设你有一个 Base64 编码的字符串 encoded_data = "gAAAAABmK1YeWb24sQcKaJVtnmeoexGo3-W8dJlNEFrLZzBhtpZPUglAkG-VNzMBnLiY14vRuOORZen24-I0wVytnbNa61LO0UY2bZqF4k6vugsPGCgPUT5vvvm7hYlG3FcGwTG1zNM6EMfGelC2vS-LTFjByMwQ8AB_YjLtkRFaJ4nHEgUexow=" find_base64_truncation(encoded_data=encoded_data) # Base64 解码 # decoded_data = base64.b64decode(encoded_data) # print(decoded_data)