Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JenniferNorthrup/c5b7e4c5890657183cf50d8f9f80f8b2 to your computer and use it in GitHub Desktop.

Select an option

Save JenniferNorthrup/c5b7e4c5890657183cf50d8f9f80f8b2 to your computer and use it in GitHub Desktop.
Job app quick request - great way to verify that applicants aren't bots!
# {"traits":
# ["Careful", "Curious", "Methodical", "Driven", "Cooperative"],
# "key": "Wutwut-abc123ed",
# "meta":
# {"description": "Enclosed are some traits that great engineers exhibit. Using the key, make a "
# "JSON array using the hex digest of the blake2b hash for each trait "
# "(digest size=64). POST it back to the endpoint. If the hashes are "
# "correct you will get a Verification ID."}
# }
import requests
from hashlib import blake2b
#Note: This is not a suitable solution for production, for a variety of reasons.
#Most notably, the requests library uses urllib3 under the hood, which only supports Open SSL 1.1.1
response = requests.get("https://api.somebusinessname.com/buildstuff", auth=None)
data = response.json()
traits = data["traits"]
key = data["key"]
def hashing_digester(trait):
trait_hash = blake2b(trait.encode(), digest_size=64, key=key.encode())
return trait_hash.hexdigest()
digests = list(map(hashing_digester, traits))
result = requests.post("https://api.somebusinessname.com/buildstuff", json=digests)
print(result.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment