File: //home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Hash/__pycache__/SHA1.cpython-310.pyc
o
we" � @ sh d dl T d dlmZmZmZmZmZmZmZ edd�Z G dd� de
�Zddd �Zej
Z
ejZd
d� ZdS )
� )�*)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptrzCrypto.Hash._SHA1a�
#define SHA1_DIGEST_SIZE 20
int SHA1_init(void **shaState);
int SHA1_destroy(void *shaState);
int SHA1_update(void *hs,
const uint8_t *buf,
size_t len);
int SHA1_digest(const void *shaState,
uint8_t digest[SHA1_DIGEST_SIZE]);
int SHA1_copy(const void *src, void *dst);
int SHA1_pbkdf2_hmac_assist(const void *inner,
const void *outer,
const uint8_t first_digest[SHA1_DIGEST_SIZE],
uint8_t final_digest[SHA1_DIGEST_SIZE],
size_t iterations);
c @ sP e Zd ZdZdZdZdZddd�Zdd � Zd
d� Z dd
� Z
dd� Zddd�ZdS )�SHA1Hasha� A SHA-1 hash object.
Do not instantiate directly.
Use the :func:`new` function.
:ivar oid: ASN.1 Object ID
:vartype oid: string
:ivar block_size: the size in bytes of the internal message block,
input to the compression function
:vartype block_size: integer
:ivar digest_size: the size in bytes of the resulting hash
:vartype digest_size: integer
� �@ z
1.3.14.3.2.26Nc C sL t � }t�|�� �}|rtd| ��t|�� tj�| _|r$| � |� d S d S )N�!Error %d while instantiating SHA1)
r �
_raw_sha1_lib� SHA1_init�
address_of�
ValueErrorr �get�SHA1_destroy�_state�update)�self�data�state�result� r �I/home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Hash/SHA1.py�__init__H s ���zSHA1Hash.__init__c C s4 t �| j�� t|�tt|���}|rtd| ��dS )z�Continue hashing of a message by consuming the next chunk of data.
Args:
data (byte string/byte array/memoryview): The next chunk of the message being hashed.
r
N)r �SHA1_updater r r r �lenr )r r r r r r r S s
���zSHA1Hash.updatec C s4 t | j�}t�| j�� |�}|rtd| ��t|�S )z�Return the **binary** (non-printable) digest of the message that has been hashed so far.
:return: The hash digest, computed over the data processed so far.
Binary form.
:rtype: byte string
r
)r �digest_sizer �SHA1_digestr r r r )r �bfrr r r r �digesta s
��zSHA1Hash.digestc C s d� dd� | �� D ��S )z�Return the **printable** digest of the message that has been hashed so far.
:return: The hash digest, computed over the data processed so far.
Hexadecimal encoded.
:rtype: string
� c S s g | ]}d t |� �qS )z%02x)�bord)�.0�xr r r �
<listcomp>z s z&SHA1Hash.hexdigest.<locals>.<listcomp>)�joinr"