You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
445 B
17 lines
445 B
from hashids import Hashids
|
|
|
|
from .conf import settings
|
|
|
|
|
|
def int_to_hashid(i, min_length=30, salt=settings.DJANGOCMS_FORMS_HASHIDS_SALT):
|
|
hashids = Hashids(salt, min_length=min_length)
|
|
return hashids.encode(i)
|
|
|
|
|
|
def hashid_to_int(hashid, min_length=30, salt=settings.DJANGOCMS_FORMS_HASHIDS_SALT):
|
|
hashids = Hashids(salt, min_length=min_length)
|
|
|
|
try:
|
|
return hashids.decode(hashid)[0]
|
|
except IndexError:
|
|
pass
|
|
|