Use alphanumeric API tokens instead of ints

This commit is contained in:
Brett Williams
2023-12-21 20:46:55 -06:00
parent d55f6a5187
commit 685297e2f2
2 changed files with 20 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import os
import platform
import shutil
import socket
import string
import subprocess
from datetime import datetime
@@ -156,3 +157,19 @@ def is_localhost(comparison_hostname):
return comparison_hostname == local_hostname
except AttributeError:
return False
def num_to_alphanumeric(num):
# List of possible alphanumeric characters
characters = string.ascii_letters + string.digits
# Make sure number is positive
num = abs(num)
# Convert number to alphanumeric
result = ""
while num > 0:
num, remainder = divmod(num, len(characters))
result += characters[remainder]
return result[::-1] # Reverse the result to get the correct alphanumeric string