%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.6/site-packages/pyzor/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.6/site-packages/pyzor/__pycache__/account.cpython-36.pyc

3

�2�^�	�@sjdZddlZddlZddlZejfdd�Zejfdd�Zdd�ZGd	d
�d
e�Z	dd�Z
e	ejdd
�ZdS)z�A collection of utilities that facilitate working with Pyzor accounts.

Note that accounts are not necessary (on the client or server), as an
"anonymous" account always exists.�NcCsN|j�j�jd�}|�}|j||�j��|jd||fjd��|j�j�S)z�Converts the key, timestamp (epoch seconds), and msg into a digest.

    lower(H(H(M) + ':' T + ':' + K))
    M is message
    T is integer epoch timestamp
    K is hashed_key
    H is the hash function (currently SHA1)
    �utf8z:%d:%s)Z	as_string�strip�encode�update�digest�	hexdigest�lower)Z
hashed_key�	timestamp�msg�hash_r�r�/usr/lib/python3.6/account.py�sign_msgs
	rcCs&d||j�fjd�}||�j�j�S)z�Returns the hash key for this username and password.

    lower(H(U + ':' + lower(K)))
    K is key (hex string)
    U is username
    H is the hash function (currently SHA1)
    z%s:%sr)rrr)�key�userr�resultrrr
�hash_keysrcCsnt|d�}|d}|d}ttj�|�tjkr<tjd��t||�}|d=t|||�}||krjtjd��dS)aVerify that the provided message is correctly signed.

    The message must have "User", "Time", and "Sig" headers.

    If the signature is valid, then the function returns normally.
    If the signature is not valid, then a pyzor.SignatureError() exception
    is raised.ZTimeZUserZSigz#Timestamp not within allowed range.zInvalid signature.N)�int�abs�time�pyzorZMAX_TIMESTAMP_DIFFERENCEZSignatureErrorrr)r
Zuser_keyr	rZprovided_signatureZhashed_user_keyZcorrect_signaturerrr
�verify_signature(s

rc@seZdZdd�ZdS)�AccountcCs||_||_||_dS)N)�username�saltr)�selfrrrrrr
�__init__@szAccount.__init__N)�__name__�
__module__�__qualname__rrrrr
r?srcCs8y|jd�\}}Wntk
r.td��YnX||fS)N�,zdInvalid number of parts for key; perhaps you forgot the comma at the beginning for the salt divider?)�split�
ValueError)�srrrrr
�key_from_hexstrFs
r$�)
�__doc__rZhashlibrZsha1rrr�objectrr$Zanonymous_userZAnonymousAccountrrrr
�<module>s	

Zerion Mini Shell 1.0