Skip to content

Instantly share code, notes, and snippets.

@LeRoiDesKiwis
Created July 12, 2020 10:15
Show Gist options
  • Save LeRoiDesKiwis/3e38cb7dcd594169b1353154ee608533 to your computer and use it in GitHub Desktop.
Save LeRoiDesKiwis/3e38cb7dcd594169b1353154ee608533 to your computer and use it in GitHub Desktop.
from datetime import datetime
class Decomposer:
def __init__(self, binary, default_cursor):
self.__cursor = 0
self.dico = {}
self.__binary = binary
self.__cursor2 = default_cursor
def add(self, name, index):
difference = self.__cursor2-index
self.dico[name] = self.__binary[self.__cursor:difference+self.__cursor]
self.__cursor = difference+self.__cursor
self.__cursor2 = index
def get_dico_decimal(self):
return {key:int(binary, 2) for (key, binary) in self.dico.items()}
def crop(text, length_expected):
difference = length_expected-len(text)
if difference >= 0:
return "0"*difference+text
else:
return text[-difference::]
def discord_epoch(raw_epoch):
epoch = raw_epoch+1420070400000
return datetime.fromtimestamp(epoch/1000.0)
id = ""
while not id.isnumeric():
id = input("id : ")
id = crop(bin(int(id))[2::], 64)
decomposer = Decomposer(id, len(id))
decomposer.add("epoch", 22)
decomposer.add("internal worker ID", 17)
decomposer.add("internal process ID", 12)
decomposer.add("ID incremented for any ID generated", 0)
print("\n---- BINARY ----")
for (key, value) in decomposer.dico.items():
print(f"{key} : {value}")
print("\n---- DECIMAL ----")
dico_decimal = decomposer.get_dico_decimal()
for (key, value) in dico_decimal.items():
print(f"{key} : {value}")
print("\n---- OTHERS INFORMATIONS ----")
print("creation date : "+str(discord_epoch(dico_decimal['epoch'])))
print("\n\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment