Last active
July 2, 2022 18:28
-
-
Save hclivess/dae3ab9f759f8ecadcb5d1ac8f4ea4db to your computer and use it in GitHub Desktop.
word miner
This file contains hidden or 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 random | |
import requests | |
import re | |
def fetch(max_length=12, min_length=6): | |
title = None | |
while not title or min_length < len(title) > max_length: | |
url = "https://en.wikipedia.org/wiki/Special:Random" | |
mashup = requests.get(url).text | |
title = re.findall("<title>(.*)\\s-", mashup, flags=re.MULTILINE)[0] | |
print("fetching...") | |
return title | |
def create_nonce(length: int = 25, letters="test run"): | |
return "".join(random.choice(letters) for i in range(length)) | |
desired = fetch() | |
while True: | |
found = "" | |
attempts = 0 | |
while found != desired: | |
attempts += 1 | |
found = create_nonce(length=len(desired), letters=desired) | |
if attempts % (len(desired) ** 5) == 0: | |
print(found) | |
print(found.lower()) | |
for letter in desired: | |
print(letter.lower()) | |
print(f"It took me {attempts} attempts to figure this out.\n") | |
c = input("Continue?\n") | |
accepted = ["y", "yes", ""] | |
if not c.lower() in accepted: | |
quit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment