n = 59621113332281337
tmp = 0
while n > 0:
tmp = (tmp * 10) + (n % 10)
n //= 10
n = tmp
while n > 0:
print(n % 10, end=" ")
n //= 10
import math
n = 59621113332281337
power = math.floor(math.log10(n))
rank = 10 ** power
while n > 0:
digit = n // rank
print(digit, end=" ")
n -= digit * rank
rank //= 10
def solution(func_map, func_filter, data):
filtered_data = filter(func_filter, data)
mapped_data = map(func_map, filtered_data)
for i, data in enumerate(mapped_data):
if i % 2 == 0:
yield data
aiohttp
(можно заменить на requests) и pycryptodome
import json
import hashlib
import asyncio
import aiohttp
from Crypto.Cipher import AES
URL = "https://proverkacheka.com"
API = "/api/v1/check/get"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0",
"Referer": "https://proverkacheka.com/",
"Origin": "https://proverkacheka.com",
}
def compute_token(qrraw: str, qr: str) -> str:
base = qrraw + qr
d = "0"
for i in range(10000):
h = hashlib.md5((base + (d := str(i))).encode()).hexdigest()
if len(h.split("0")) - 1 > 4:
break
return "0." + d
async def get_crypted_json(qrraw: str, qr: str) -> bytes:
form = aiohttp.FormData()
form.add_field(name="qrraw", value=qrraw)
form.add_field(name="qr", value=qr)
form.add_field(name="token", value=compute_token(qrraw, qr))
async with aiohttp.ClientSession(headers=headers) as client:
# Получаем куки
await client.get(URL)
response = await client.post(URL + API, data=form, headers={"Cookie": "ENGID=1.1"})
if "+crypto" not in response.headers["Content-Type"]:
raise ValueError("Invalid token")
return await response.read()
async def main() -> None:
basekey = "38s91"
decryptkey = "f65nm"
qrraw = "t=20201017T1923&s=1498.00&fn=9282440300669857&i=25151&fp=1186123459&n=1"
qr = "3"
crypted_json = await get_crypted_json(qrraw, qr)
crypted_data, nonce = crypted_json[:-12], crypted_json[-12:]
key = hashlib.sha256((basekey + decryptkey).encode()).digest()
cipher = AES.new(key=key, mode=AES.MODE_GCM, nonce=nonce)
decrypted_data = cipher.decrypt(crypted_data)
# В plain_text присутствует какие-то лишние символы на конце, скорее всего паддинг для зашифровки. Не проверял.
plain_text = decrypted_data.decode(errors="ignore")
# Отрезаем лишние символы справа
pt = plain_text[:plain_text.rfind("}") + 1]
with open("decoded.json", "wt", encoding="utf-8") as fp:
loaded = json.loads(pt)
json.dump(loaded, fp, ensure_ascii=False, indent=4)
if __name__ == "__main__":
asyncio.run(main())
import math
a = 12345678982734
b = 12351
c = 123
d = 12
def get_first4(n):
power = math.ceil(math.log10(n)) - 4 # Число 4 = нужное количество разрядов слева
if power < 0: # Проверка, что бы не возводить в отрицательную степень
power = 0
return n // 10 ** power
print(get_first4(a), get_first4(b))
print(get_first4(c), get_first4(d))
import api
import config
from api import logger
import time
import random
from api import servers
import utils
from colorama import init
from termcolor import colored
init()
@logger.catch
def start():
main = api.DurakClient(_type="main")
for _ in range(100):
server = random.choice(servers)
logger.info(f"[INFO] Присоеденился к {server[0]+':'+str(server[1])}")
print(colored('EASY: [INFO] Проект был создан Easy Team', 'red'))
main.connect(server)
key2 = main.getSessionKey()
main.verifySession(key2)
main.auth(config.TOKEN)
bot = api.DurakClient(_type="bot")
bot.connect(server)
key = bot.getSessionKey()
bot.verifySession(key)
token = ""
while not token:
try:
token = bot.register()
except:
continue
bot.auth(token)
bot.sendFriendRequest()
_id1 = ""
while not _id1:
_id1 = main.getMessagesUpdate()
main.acceptFriendRequest(_id1)
pwd = bot.createGame()
bot.inviteToGame()
_id = ""
while not _id:
_id = main.getInvites()
main.join(_id, pwd)
bot.ready()
main.ready()
bot.waitingFor()
main.waitingFor()
time.sleep(0.3)
bot.leave(_id)
time.sleep(0.4)
main.leave(_id)
main.deleteFriend(_id1)
bot.sendFriendRequest()
_id2 = ""
while not _id2:
_id2 = main.getMessagesUpdate()
time.sleep(1.5)
main.acceptFriendRequest(_id2)
time.sleep(1.5)
pwd = bot.createGame2()
bot.inviteToGame()
_id3 = ""
while not _id3:
_id3 = main.getInvites()
main.join(_id3, pwd)
bot.ready()
main.ready()
bot.waitingFor()
main.waitingFor()
time.sleep(0.3)
bot.leave(_id3)
time.sleep(0.4)
main.leave(_id3)
main.deleteFriend(_id2)
bot.exit()
time.sleep(1)
start()
def change(arr, indexes, value):
head, tail = indexes[:-1], indexes[-1]
for i in head:
arr = arr[i]
arr[tail] = value
>>> arr = [0, 1, 5, [5, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0, 0, 0, 0]]
>>> change(arr, [3, 1, 0], 999)
>>> arr
[0, 1, 5, [5, [999, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0, 0, 0, 0]]
import re
import zlib
import base64
with open('epreuve_BAC_2004.pdf', 'rb') as input_file, open('picture.jpg', 'wb') as output_file:
encoded_text = input_file.read()
match = re.search(b'77 0 obj.*?stream(.*?)endstream', encoded_text, re.S)
stream = match.group(1).strip(b'\n')
decompressed = zlib.decompress(stream)
output_file.write(base64.b64decode(decompressed))