Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 KeyAuth
Copyright (c) 2022 KeyAuth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# KeyAuth-Python-Example
KeyAuth Python Example For The https://keyauth.win Authentication system.
KeyAuth Python Example For The https://keyauth.cc Authentication system.

# Instructions

Expand All @@ -20,4 +20,4 @@ Setup video: https://www.youtube.com/watch?v=L2eAQOmuUiA
**What is KeyAuth?**

KeyAuth is a GameChanging authentication system. We have never-seen before features, and we listen to our customers.
Feel free to join https://keyauth.win/discord/ if you have questions or suggestions.
Feel free to join https://keyauth.cc/discord/ if you have questions or suggestions.
74 changes: 73 additions & 1 deletion keyauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,78 @@ def log(self, message):
}

self.__do_request(post_data)

def fetchOnline(self):
self.checkinit()
init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest()

post_data = {
"type": binascii.hexlify(("fetchOnline").encode()),
"sessionid": binascii.hexlify(self.sessionid.encode()),
"name": binascii.hexlify(self.name.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"init_iv": init_iv
}

response = self.__do_request(post_data)
response = encryption.decrypt(response, self.enckey, init_iv)

json = jsond.loads(response)

if json["success"]:
if json["users"]["0"]:
return None ## THIS IS ISSUE ON KEYAUTH SERVER SIDE 6.8.2022 so it will return none if it is not an array.
else:
return json["users"]
else:
return None

def chatGet(self, channel):
self.checkinit()
init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest()

post_data = {
"type": binascii.hexlify(("chatget").encode()),
"channel": encryption.encrypt(channel, self.enckey, init_iv),
"sessionid": binascii.hexlify(self.sessionid.encode()),
"name": binascii.hexlify(self.name.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"init_iv": init_iv
}

response = self.__do_request(post_data)
response = encryption.decrypt(response, self.enckey, init_iv)

json = jsond.loads(response)

if json["success"]:
return json["messages"]
else:
return None

def chatSend(self, message, channel):
self.checkinit()
init_iv = SHA256.new(str(uuid4())[:8].encode()).hexdigest()

post_data = {
"type": binascii.hexlify(("chatsend").encode()),
"message": encryption.encrypt(message, self.enckey, init_iv),
"channel": encryption.encrypt(channel, self.enckey, init_iv),
"sessionid": binascii.hexlify(self.sessionid.encode()),
"name": binascii.hexlify(self.name.encode()),
"ownerid": binascii.hexlify(self.ownerid.encode()),
"init_iv": init_iv
}

response = self.__do_request(post_data)
response = encryption.decrypt(response, self.enckey, init_iv)

json = jsond.loads(response)

if json["success"]:
return True
else:
return False

def checkinit(self):
if not self.initialized:
Expand All @@ -430,7 +502,7 @@ class application_data_class:
numUsers = numKeys = app_ver = customer_panel = onlineUsers = ""
# region user_data
class user_data_class:
username = ip = hwid = expires = createdate = lastlogin = subscription = ""
username = ip = hwid = expires = createdate = lastlogin = subscription = subscriptions ""

user_data = user_data_class()
app_data = application_data_class()
Expand Down
23 changes: 23 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def getchecksum():
version = "1.0",
hash_to_check = getchecksum()
)

print(f"""
App data:
Number of users: {keyauthapp.app_data.numUsers}
Expand Down Expand Up @@ -101,6 +102,18 @@ def getchecksum():
#* example to send normal request with no POST data
#data = keyauthapp.webhook("WebhookID", "?type=resetuser&user=username")

#* Get chat messages
#messages = keyauthapp.chatGet("CHANNEL")

#Messages = ""
#for i in range(len(messages)):
# Messages += datetime.utcfromtimestamp(int(messages[i]["timestamp"])).strftime('%Y-%m-%d %H:%M:%S') + " - " + messages[i]["author"] + ": " + messages[i]["message"] + "\n"

#print("\n\n" + Messages)

#* Send chat message
#keyauthapp.chatSend("MESSAGE", "CHANNEL")

#endregion

print("\nUser data: ")
Expand All @@ -117,6 +130,16 @@ def getchecksum():

print(f"[{i + 1} / {len(subs)}] | Subscription: {sub} - Expiry: {expiry} - Timeleft: {timeleft}")

onlineUsers = keyauthapp.fetchOnline()
OU = "" ## KEEP THIS EMPTY FOR NOW, THIS WILL BE USED TO CREATE ONLINE USER STRING.
if onlineUsers == None:
OU = "No online users"
else:
for i in range(len(onlineUsers)):
OU += onlineUsers[i]["credential"] + " "

print("\n" + OU + "\n")


print("Created at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.createdate)).strftime('%Y-%m-%d %H:%M:%S'))
print("Last login at: " + datetime.utcfromtimestamp(int(keyauthapp.user_data.lastlogin)).strftime('%Y-%m-%d %H:%M:%S'))
Expand Down