change to use pybase64

This commit is contained in:
LanQian 2024-05-19 03:27:10 +08:00
parent 09386d857b
commit d4d0b8aa92
3 changed files with 5 additions and 6 deletions

View File

@ -1,6 +1,6 @@
import base64
import io
import pybase64
from PIL import Image
from utils.Client import Client
@ -9,7 +9,7 @@ from utils.Client import Client
async def get_file_content(url):
if url.startswith("data:"):
mime_type, base64_data = url.split(';')[0].split(':')[1], url.split(',')[1]
file_content = base64.b64decode(base64_data)
file_content = pybase64.b64decode(base64_data)
return file_content, mime_type
else:
client = Client()

View File

@ -1,11 +1,11 @@
import asyncio
import base64
import json
import random
import string
import time
import uuid
import pybase64
import websockets
from api.files import get_file_content
@ -76,7 +76,7 @@ async def wss_stream_response(websocket, conversation_id):
data = resultObj.get("data", {})
if conversation_id != data.get("conversation_id", ""):
continue
decoded_bytes = base64.b64decode(data.get("body", None))
decoded_bytes = pybase64.b64decode(data.get("body", None))
yield decoded_bytes
else:
print("No message received within the specified time.")

View File

@ -1,4 +1,3 @@
import base64
import hashlib
import json
import random
@ -362,7 +361,7 @@ def generate_answer(seed, diff, config):
if hash_value[:diff_len] <= target_diff:
return base_encode.decode()
return "wQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D" + base64.b64encode(f'"{seed}"'.encode()).decode()
return "wQ8Lk5FbGpA2NcR9dShT6gYjU7VxZ4D" + pybase64.b64encode(f'"{seed}"'.encode()).decode()
def get_requirements_token(config):