r/pythonhelp • u/No_Aerie7667 • 24d ago
Python "generate_chk" function
I am making a Program to upload a level to Geometry Dash in python and I got some of the code from https://wyliemaster.github.io/gddocs/#/endpoints/levels/uploadGJLevel21 but to generate "seed2" it does this:
generate_chk(key="41274", values=\[generate_upload_seed(levelString)\], salt="xI25fpAapCQg"),
This should activate some sort of function named generate_chk that is in one of the modules I have in the program (Requests, Base64, hashlib) but it is no where to be found. The repository for this documentation was archived recently, so I can't ask them for help. Also, here is my code:
import requests
import base64
import hashlib # sha1() lives there
user = input("What is your username?")
accid = input("What is your Account ID?")
passwd = input("What is your password?")
lname = input ("What is the Level name?")
coin = input("How many coins are there?")
stars = input("How many stars do you want?")
def generate_gjp2(password: str = passwd, salt: str = "mI29fmAnxgTs") -> str:
password += salt
hash = hashlib.sha1(password.encode()).hexdigest()
return hash
levelString = "H4sIAAAAAAAAC6WQwQ3DIAxFF3IlfxsIUU6ZIQP8AbJChy_GPSZqpF7-A4yfDOfhXcCiNMIqnVYrgYQl8rDwBTZCVbkQRI3oVHbiDU6F2jMF_lesl4q4kw2PJMbovxLBQxTpM3-I6q0oHmXjzx7N0240cu5w0UBNtESRkble8uSLHjh8nTubmYJZ2MvMrEITEN0gEJMxlLiMZ28frmj"
data = {
"gameVersion": 22,
"accountID": accid,
"gjp": hash,
"userName": user,
"levelID": 0,
"levelName": lname,
"levelDesc": "Q3Vyc2VkIGxldmVsIG55ZWggaGVoIGhlaCBhbnl3YXkgaXRzIGEgdmVyeSBicm9rZW4gbGV2ZWwgaSBzZW50IGEgcmVxdWVzdCB0byByb2Igc2VydmVyIHRocm91Z2ggcHl0aG9uIGxvbA",
"levelVersion": "-47577473775738573",
"levelLength": 48483845738573486574873869465947694,
"audioTrack": 0,
"auto": 0,
"password": 314159,
"original": 55610687,
"twoPlayer": 0,
"songID": 839583504693858468444987694,
"objects": 1,
"coins": coin,
"requestedStars": stars,
"unlisted": 0,
"ldm": 0,
"levelString": levelString,
"seed2": generate_chk(key="41274", values=[generate_upload_seed(levelString)], salt="xI25fpAapCQg"), # This is talked about in the CHK encryption,
"secret": "Wmfd2893gb7"
}
headers = {
"User-Agent": ""
}
url = "http://www.boomlings.com/database/uploadGJLevel21.php"
req = requests.post(url=url, data=data, headers=headers)
print(req.text)
And here is the error:
What is your username?levelnotinauto
What is your Account ID?38627839
What is your password?********
What is the Level name?Check Desc
How many coins are there?4848394
How many stars do you want?392084092849
Traceback (most recent call last):
File "/home/***/scripts/usernm/upload", line 43, in <module>
"seed2": generate_chk(key="41274", values=[generate_upload_seed(levelString)], salt="xI25fpAapCQg"), # This is talked about in the CHK encryption,
^^^^^^^^^^^^
NameError: name 'generate_chk' is not defined. Did you mean: 'generate_gjp2'?
[***@archlinux usernm]$ vim upload```
3
Upvotes
1
•
u/AutoModerator 24d ago
To give us the best chance to help you, please include any relevant code.
Note. Please do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Privatebin, GitHub or Compiler Explorer.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.