11 lines
280 B
Python
11 lines
280 B
Python
from hashids import Hashids
|
|
from django.conf import settings
|
|
|
|
hashids = Hashids(min_length=8, salt=settings.HASHIDS_SALT)
|
|
|
|
def encode_id(id):
|
|
return hashids.encode(id)
|
|
|
|
def decode_id(hashid):
|
|
decoded = hashids.decode(hashid)
|
|
return int(decoded[0]) if decoded else None |