forked from mtusi2026/mtusi2026lab2
ЛР 2: мессенджер на PostgreSQL и сессии в Redis
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import hashlib
|
||||
import secrets
|
||||
|
||||
|
||||
def create_token() -> str:
|
||||
return secrets.token_urlsafe(32)
|
||||
|
||||
|
||||
def session_key(token: str) -> str:
|
||||
digest = hashlib.sha256(token.encode('utf-8')).hexdigest()
|
||||
return f'session:{digest}'
|
||||
Reference in New Issue
Block a user