Created
August 25, 2024 02:13
-
-
Save tildejustin/1f59c11bad34da2c3b50f898edf2d041 to your computer and use it in GitHub Desktop.
20w14inf something or other sitting on my hard drive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import random | |
# 264^4 dimensions | |
# need hash to equal 2 | |
def get_string(input: str) -> str: | |
# stolen from net.minecraft.world.dimension.DimensionHashHelper$getHash | |
return input + ":why_so_salty#LazyCrypto" | |
def get_hash(input: str) -> int: | |
bytes = hashlib.sha256(get_string(input).encode()).digest()[0:4] | |
# stolen from com.google.common.hash.HashCode$asInt | |
asint: int = (bytes[0] & 0xFF) | ((bytes[1] & 0xFF) << 8) | ((bytes[2] & 0xFF) << 16) | ((bytes[3] & 0xFF) << 24) | |
# also stolen from net.minecraft.world.dimension.DimensionHashHelper$getHash | |
return asint & 2147483647 | |
# sanity check | |
assert get_hash("abatised redivides") == 2 | |
found = False | |
count = 22500000000 | |
while not found: | |
# candidate = "".join(random.choice( | |
# "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890`,.; ") for _ in range(random.choice([5, 6, 7, 8])) | |
# ) | |
candidate = str(count) | |
dimension = get_hash(candidate) | |
if dimension == 2: | |
print(candidate, dimension) | |
# found = True | |
with open("result.txt", "a") as file: | |
file.write(candidate + "\n") | |
count = count + 1 | |
if count % 500000000 == 0: | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment