1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-27 10:07:22 +00:00
bazarr/libs/cork/sessions.py
halali cc3c4462a0 Login form #127
* Initial commit

* Fix cookies

* Continue work

* Login error msg

* Reimplement Basic auth

* Some improvements

* Reimplement Basic auth

* Some improvements

* Change validation key for cookies

* Some Changes

* Add client side control of password when changing username

* Some changes
2018-09-11 22:32:09 -04:00

23 lines
533 B
Python

import json
import base64
import hmac
from Crypto.Cipher import AES
def _strcmp(a, b):
"""Compares two strings while preventing timing attacks. Execution time
is not affected by lenghth of common prefix on strings of the same length"""
return not sum(0 if x==y else 1 for x, y in zip(a, b)) and len(a) == len(b)
class SecureSession(object):
def __init__(self):
json()
base64.b64encode(hmac.new(tob(key), msg).digest())):
return pickle.loads(base64.b64decode(msg))