{}
run-icon
main.py
#!/usr/bin/env python3 """ GuardPinTime (Java → Python) — fixed time constants Edit the constants below to compute the code for any date/time. """ from datetime import datetime import hashlib # ========================================================= # >>>>> EDIT THESE CONSTANTS <<<<< YEAR = 2025 MONTH = 11 # 1–12 (Java uses month+1, Python already stores it as 1..12) DAY = 2 # 1–31 HOUR = 10 # 0–23 MINUTE = 30 # 0–59 MASTER_KEY = "timurator" # ========================================================= def _signed_byte(b: int) -> int: """Convert 0..255 → Java signed byte (-128..127)""" return b - 256 if b > 127 else b def _java_abs_digit(b: int) -> str: """Emulates String.valueOf(Math.abs(byte)).charAt(0)""" sb = _signed_byte(b) x = abs(sb) return str(x)[0] # take first digit of decimal string def encrypt_time(): # Order and fields follow the decompiled Java exactly: md = hashlib.sha256() md.update(str(MONTH).encode("utf-8")) # (month + 1) in Java, month is already 1..12 here md.update(str(YEAR).encode("utf-8")) md.update(str(MINUTE).encode("utf-8")) # Append decimal values of master key bytes (Java: builder.append(byteValue)) key_bytes = MASTER_KEY.encode("utf-8") decimal_concat = "".join(str(b if b < 128 else b - 256) for b in key_bytes) md.update(decimal_concat.encode("utf-8")) digest = md.digest() # Build 4 characters according to exact Java logic ch0 = _java_abs_digit(digest[0]) ch1 = _java_abs_digit(digest[DAY % len(digest)]) # day index ch2 = _java_abs_digit(digest[HOUR % len(digest)]) # hour index ch3 = _java_abs_digit(digest[-1]) # last byte return f"{ch0}{ch1}{ch2}{ch3}" if __name__ == "__main__": code = encrypt_time() print("Generated code:", code)
Output