Untitled
python
24 days ago
1.8 kB
1
Indexable
Never
import requests import json import base64 import pyotp def main(): # Replace these variables with your own information email = "shikharrai114@gmail.com" # Your email address gist_url = "https://gist.github.com/str1ke007/65823c141551fafc5d68020b4895550a" # Your gist URL solution_language = "python" # Your solution language # Construct the JSON payload payload = { "github_url": gist_url, "contact_email": email, "solution_language": solution_language } # Generate a TOTP password based on the specified criteria shared_secret = email + "HENNGECHALLENGE003" encoded_secret = base64.b32encode(shared_secret.encode()).decode() totp = pyotp.TOTP(encoded_secret, digest="sha512", interval=30, digits=10) totp_password = totp.now() # Encode the credentials for the Authorization header credentials = f"{email}:{totp_password}" encoded_credentials = base64.b64encode(credentials.encode()).decode() # Make the HTTP POST request with the JSON payload and authentication headers url = "https://api.challenge.hennge.com/challenges/003" headers = { "Content-Type": "application/json", "Authorization": f"Basic {encoded_credentials}" } # Send the HTTP POST request try: response = requests.post(url, data=json.dumps(payload), headers=headers) # Check the response status code if response.status_code == 200: print("Success! Check the response for further instructions.") else: print(f"HTTP Error: {response.status_code}") print("Response Content:") print(response.text) # Print the response content for debugging except Exception as e: print(f"Error: {e}") if __name__ == "__main__": main()