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.
23 lines
725 B
23 lines
725 B
1 year ago
|
from django.conf import settings
|
||
|
from django.utils.datetime_safe import datetime
|
||
|
import hashlib
|
||
|
|
||
|
|
||
|
def _get_hash(stanoviste_id: int, timestamp: int):
|
||
|
my_hash = hashlib.new("md5")
|
||
|
my_hash.update(str(stanoviste_id).encode())
|
||
|
my_hash.update(str(timestamp).encode())
|
||
|
return my_hash.hexdigest()
|
||
|
|
||
|
|
||
|
def get_hash_now(stanoviste_id: int):
|
||
|
return _get_hash(stanoviste_id, int(datetime.now().timestamp() // settings.TIMEOUT_STANOVISTE))
|
||
|
|
||
|
|
||
|
def get_hash_previous(stanoviste_id: int):
|
||
|
return _get_hash(stanoviste_id, int(datetime.now().timestamp() // settings.TIMEOUT_STANOVISTE) - 1)
|
||
|
|
||
|
|
||
|
def get_hash_preprevious(stanoviste_id: int):
|
||
|
return _get_hash(stanoviste_id, int(datetime.now().timestamp() // settings.TIMEOUT_STANOVISTE) - 2)
|