Hashing and parsing - blake2b
Verification step for application that states this
Send a GET request to https://api.close.com/buildwithus/ Follow the instructions provided in the response. Enter your Verification ID in the space provided here.
Using the GET
request to that url you get the following for example
{
"traits": [
"Craftsman",
"Pragmatic",
"Curious",
"Methodical",
"Driven",
"Collaborator"
],
"key": "Close-9bae741a",
"meta": {
"description": "Enclosed are some traits that [Joe](https://www.linkedin.com/in/jkemp101/) believes great engineers exhibit. Using the included UTF-8 `key`, construct a JSON array using the lowercase hex digest of the blake2b hash for each trait (digest size=64). POST this bare array back to this endpoint. Example array: [\"1f9ec19c7...57fd27e5\", \"79c72b47088...bf13026c\", ...] If the hashes are correct you will get a Verification ID you should include in your application. 400 responses indicate a problem with the hashes in your array. Note, the key rotates each day around midnight EST."
}
}
First off you can compute with an online tool here BLAKE2b, but can also work it out with Python like so:
from hashlib import blake2b
import httpx
from icecream import ic
def hash_input(input_data: str, key: str, encoding_type ='utf-8') -> str:
key_bytes = key.encode(encoding_type)
to_hash = input_data.encode(encoding_type)
return blake2b(to_hash, key=key_bytes).hexdigest()
if __name__ == "__main__":
endpoint_url = "https://api.close.com/buildwithus/";
data = (httpx.get(endpoint_url)).json()
hash_results = ic([hash_input(input, data['key']) for input in data['traits']])
response = httpx.post(endpoint_url, json=hash_results)
ic((response.content.decode("utf-8")).strip().split(":").pop().strip())