i want to rewrite an already written script with another use for the application fruitcraft, this the code "import base64
import time
import os
from urllib.parse import unquote
import json
import requests
import random
import string
os.system("cls")



var = 'load_code_here'



code=input('edata: ')
code=unquote(code.replace("edata=",""))



bs64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
xor = [24, 22, 49, 41, 12, 19, 12, 52, 12, 54, 25, 33, 28, 38, 5, 58, 12, 19, 0, 53, 13, 22, 5, 46, 29, 6, 49, 37, 28, 35, 8, 56, 14, 6, 9, 33, 28, 54, 21, 36]



def getIndex(c) :
    if (ord(c) >= ord('A') and ord(c) <= ord('Z')) :
        return ord(c) - ord('A')
    elif (ord(c) >= ord('a') and ord(c) <= ord('z')) :
        return ord(c) - ord('a') + 26
    elif (ord(c) >= ord('0') and ord(c) <= ord('9')) :
        return ord(c) - ord('0') + 52
    elif (c == '+') :
        return 62
    elif (c == '/') :
        return 63
    else :
        return -1



def FruitCraftDecode(st):
    st = list(st)
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = str(base64.b64decode(''.join(st)))[2:-1]
    return st



def FruitCraftEncode(st):
    st = list(str(base64.b64encode(st.encode()))[2:-1])
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = ''.join(st)
    return st



def send(url0, data, c):
    #time.sleep(1)
    url = "http://iran.fruitcraft.ir/"+url0
    headers = {
        "Cookie": "FRUITPASSPORT="+c,
        "Host": "iran.fruitcraft.ir",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 14; SM-B980N Build/TP1A.230124.014)"
    }
    data = {
        "edata":data
    }



    response = requests.post(url, headers=headers, data=data, verify=False)
    return(response.text)
def get_random_string(length):
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(length))
    return(result_str)
x = int(input("Count: "))
for x in range(x):
    load = var.replace("edata=","")
    cookie = get_random_string(32)
    result=json.loads(FruitCraftDecode(send("player/load", unquote(load), cookie)))
    print(result)
    resultofc = json.loads(FruitCraftDecode(send("live-battle/triggerability", (code), cookie)))
    print(resultofc)
" here is another script to gather values and more reference about how these scripts should be "import base64
import time
import os
from urllib.parse import unquote
import json
import requests
import random
import string
os.system("cls")


cardcode="Gk4dSENREVxSQE1YU1FGUD4NFR4BLVtcGlhUQlEZ"


bs64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
xor = [24, 22, 49, 41, 12, 19, 12, 52, 12, 54, 25, 33, 28, 38, 5, 58, 12, 19, 0, 53, 13, 22, 5, 46, 29, 6, 49, 37, 28, 35, 8, 56, 14, 6, 9, 33, 28, 54, 21, 36]


def getIndex(c) :
    if (ord(c) >= ord('A') and ord(c) <= ord('Z')) :
        return ord(c) - ord('A')
    elif (ord(c) >= ord('a') and ord(c) <= ord('z')) :
        return ord(c) - ord('a') + 26
    elif (ord(c) >= ord('0') and ord(c) <= ord('9')) :
        return ord(c) - ord('0') + 52
    elif (c == '+') :
        return 62
    elif (c == '/') :
        return 63
    else :
        return -1


def FruitCraftDecode(st):
    st = list(st)
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = str(base64.b64decode(''.join(st)))[2:-1]
    return st


def FruitCraftEncode(st):
    st = list(str(base64.b64encode(st.encode()))[2:-1])
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = ''.join(st)
    return st
#print(FruitCraftEncode("{}"));


def send(url0, data, c):
    time.sleep(1)
    url = "http://iran.fruitcraft.ir/"+url0
    headers = {
        "Cookie": "FRUITPASSPORT="+c,
        "Host": "iran.fruitcraft.ir",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 14; SM-B980N Build/TP1A.230124.014)"
    }
    data = {
        "edata":data
    }


    response = requests.post(url, headers=headers, data=data, verify=False)
    return(response.text)
    



def get_random_string(length):
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(length))
    return(result_str)



#print(result["data"]["restore_key"])
x = int(input("Count: "))
for x in range(x):
    uid = get_random_string(16)
    var = '{"game_version":"1.10.10700","udid":"'+uid+'","os_type":2,"device_name":"unknown","kochava_uid":"KAdj046kd8jfn8jd9445d9bf3974473fb4bacd0b0b454e67","model":"SM-B090LB","metrix_uid":"-","os_version":"14","appsflyer_uid":"1604098877500-8086398948478074368","store_type":"parsian"}'
    load = FruitCraftEncode(var)
    cookie = get_random_string(32)
    result=json.loads(FruitCraftDecode(send("player/load", unquote(load), cookie)))


    key = result["data"]["restore_key"]
    resultofc = json.loads(FruitCraftDecode(send("store/buycardpack", cardcode, cookie)))
    print(key)
" i want you to do the encode and decoding, this is the request text "import base64
import time
import os
from urllib.parse import unquote
import json
import requests
import random
import string
os.system("cls")


cardcode="Gk4dSENREVxSQE1YU1FGUD4NFR4BLVtcGlhUQlEZ"


bs64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
xor = [24, 22, 49, 41, 12, 19, 12, 52, 12, 54, 25, 33, 28, 38, 5, 58, 12, 19, 0, 53, 13, 22, 5, 46, 29, 6, 49, 37, 28, 35, 8, 56, 14, 6, 9, 33, 28, 54, 21, 36]


def getIndex(c) :
    if (ord(c) >= ord('A') and ord(c) <= ord('Z')) :
        return ord(c) - ord('A')
    elif (ord(c) >= ord('a') and ord(c) <= ord('z')) :
        return ord(c) - ord('a') + 26
    elif (ord(c) >= ord('0') and ord(c) <= ord('9')) :
        return ord(c) - ord('0') + 52
    elif (c == '+') :
        return 62
    elif (c == '/') :
        return 63
    else :
        return -1


def FruitCraftDecode(st):
    st = list(st)
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = str(base64.b64decode(''.join(st)))[2:-1]
    return st


def FruitCraftEncode(st):
    st = list(str(base64.b64encode(st.encode()))[2:-1])
    for i in range(0, len(st)) :
        if (st[i] == '=') :
            continue
        st[i] = bs64[getIndex(st[i]) ^ xor[i % 40]]
    st = ''.join(st)
    return st
#print(FruitCraftEncode("{}"));


def send(url0, data, c):
    time.sleep(1)
    url = "http://iran.fruitcraft.ir/"+url0
    headers = {
        "Cookie": "FRUITPASSPORT="+c,
        "Host": "iran.fruitcraft.ir",
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "User-Agent": "Dalvik/2.1.0 (Linux; U; Android 14; SM-B980N Build/TP1A.230124.014)"
    }
    data = {
        "edata":data
    }


    response = requests.post(url, headers=headers, data=data, verify=False)
    return(response.text)
    



def get_random_string(length):
    letters = string.ascii_lowercase
    result_str = ''.join(random.choice(letters) for i in range(length))
    return(result_str)



#print(result["data"]["restore_key"])
x = int(input("Count: "))
for x in range(x):
    uid = get_random_string(16)
    var = '{"game_version":"1.10.10700","udid":"'+uid+'","os_type":2,"device_name":"unknown","kochava_uid":"KAdj046kd8jfn8jd9445d9bf3974473fb4bacd0b0b454e67","model":"SM-B090LB","metrix_uid":"-","os_version":"14","appsflyer_uid":"1604098877500-8086398948478074368","store_type":"parsian"}'
    load = FruitCraftEncode(var)
    cookie = get_random_string(32)
    result=json.loads(FruitCraftDecode(send("player/load", unquote(load), cookie)))


    key = result["data"]["restore_key"]
    resultofc = json.loads(FruitCraftDecode(send("store/buycardpack", cardcode, cookie)))
    print(key)
" and this is the response "HTTP/1.1 200 OK
server: nginx/1.21.3
date: Tue, 16 Jan 2024 04:35:26 GMT
content-type: text/html; charset=UTF-8
transfer-encoding: chunked
x-powered-by: PHP/7.4.33
Expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-store, no-cache, must-revalidate
pragma: no-cache


24
Gk4aRVJARhVDSBUIRFUZFwUPAA1HSGllRQ==
0


"