Skip to content

Instantly share code, notes, and snippets.

@mcbhenwood
Created August 22, 2021 11:44
Show Gist options
  • Save mcbhenwood/052bac96efff8bbdd615c881d445092a to your computer and use it in GitHub Desktop.
Save mcbhenwood/052bac96efff8bbdd615c881d445092a to your computer and use it in GitHub Desktop.
import hashlib
EXAMPLE_COMPANY = {"name": "Acme Ltd", "id": 1234}
short_hash_of_id = hashlib.sha256(
str(EXAMPLE_COMPANY["id"]).encode("utf-8")
).hexdigest()[:7]
print(f"Folder name: {EXAMPLE_COMPANY['name']} ({short_hash_of_id})")
# Example output:
# Folder name: Acme Ltd (03ac674)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment