Skip to content

Instantly share code, notes, and snippets.

@chillu

chillu/README.md Secret

Created December 20, 2023 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chillu/fb7c1b82cb126546b5840f8a91fc502a to your computer and use it in GitHub Desktop.
Save chillu/fb7c1b82cb126546b5840f8a91fc502a to your computer and use it in GitHub Desktop.
Runn API v1 legacy identifier conversion script (Python)

Runn Legacy Identifier Conversion script

See API v1 Changelog for details

Installation

pip install hashids

Usage

python3 convert.py <my-hashid>

Example:

python3 convert.py o1kcol
Table: roles, Identifier: 49
import sys
from hashids import Hashids
salt = "GRdrheher42342@gerergwqefqwwt346SDGDFGG"
hash_length = 6
alphabet = "abcdefghijklmnopqrstuvwxyz1234567890"
tables = [
"accounts", "actuals", "assignments", "clients", "contracts",
"help_documents", "holidays", "holidays_groups", "invitations",
"milestones", "notes", "people", "phases", "project_rates",
"project_roles", "projects", "rate_cards", "role_charge_out_rate",
"roles", "schedules", "tags", "teams", "time_offs", "users"
]
def decode_hashid(hashid):
for table_name in tables:
hashids = Hashids(salt=f"{table_name}{salt}", min_length=hash_length, alphabet=alphabet)
decoded = hashids.decode(hashid)
if decoded:
return table_name, decoded[1]
return None, None
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py <hashid>")
sys.exit(1)
hashid_to_decode = sys.argv[1]
table_name, decoded_value = decode_hashid(hashid_to_decode)
if table_name and decoded_value is not None:
print(f"Table: {table_name}, Identifier: {decoded_value}")
else:
print("No matching table found for the provided hashid.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment