File: //home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Hash/__pycache__/MD4.cpython-310.pyc
o
we� � @ sh d Z ddlmZ ddlmZmZmZmZmZm Z m
Z
edd�ZG dd� de�Z
dd d
�Ze
jZe
jZdS )a�
MD4 is specified in RFC1320_ and produces the 128 bit digest of a message.
>>> from Crypto.Hash import MD4
>>>
>>> h = MD4.new()
>>> h.update(b'Hello')
>>> print h.hexdigest()
MD4 stand for Message Digest version 4, and it was invented by Rivest in 1990.
This algorithm is insecure. Do not use it for new designs.
.. _RFC1320: http://tools.ietf.org/html/rfc1320
� ��bord)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�create_string_buffer�get_raw_buffer�c_size_t�c_uint8_ptrzCrypto.Hash._MD4a�
int md4_init(void **shaState);
int md4_destroy(void *shaState);
int md4_update(void *hs,
const uint8_t *buf,
size_t len);
int md4_digest(const void *shaState,
uint8_t digest[20]);
int md4_copy(const void *src, void *dst);
c @ sP e Zd ZdZdZdZdZddd�Zdd � Zd
d� Z dd
� Z
dd� Zddd�ZdS )�MD4Hashz&Class that implements an MD4 hash
� �@ z1.2.840.113549.2.4Nc C sL t � }t�|�� �}|rtd| ��t|�� tj�| _|r$| � |� d S d S )N� Error %d while instantiating MD4)
r �_raw_md4_lib�md4_init�
address_of�
ValueErrorr �get�md4_destroy�_state�update)�self�data�state�result� r �H/home/arjun/projects/env/lib/python3.10/site-packages/Crypto/Hash/MD4.py�__init__O s ���zMD4Hash.__init__c C s4 t �| j�� t|�tt|���}|rtd| ��dS )a� Continue hashing of a message by consuming the next chunk of data.
Repeated calls are equivalent to a single call with the concatenation
of all the arguments. In other words:
>>> m.update(a); m.update(b)
is equivalent to:
>>> m.update(a+b)
:Parameters:
data : byte string/byte array/memoryview
The next chunk of the message being hashed.
r N)r �
md4_updater r r
r �lenr )r r r r r r r Z s
���zMD4Hash.updatec C s4 t | j�}t�| j�� |�}|rtd| ��t|�S )ar Return the **binary** (non-printable) digest of the message that
has been hashed so far.
This method does not change the state of the hash object.
You can continue updating the object after calling this function.
:Return: A byte string of `digest_size` bytes. It may contain non-ASCII
characters, including null bytes.
r )r �digest_sizer �
md4_digestr r r r )r �bfrr r r r �digestr s
��zMD4Hash.digestc C s d� dd� | �� D ��S )a Return the **printable** digest of the message that has been
hashed so far.
This method does not change the state of the hash object.
:Return: A string of 2* `digest_size` characters. It contains only
hexadecimal ASCII digits.
� c S s g | ]}d t |� �qS )z%02xr )�.0�xr r r �
<listcomp>� s z%MD4Hash.hexdigest.<locals>.<listcomp>)�joinr# )r r r r � hexdigest� s
zMD4Hash.hexdigestc C s2 t � }t�| j�� |j�� �}|rtd| ��|S )a4 Return a copy ("clone") of the hash object.
The copy will have the same internal state as the original hash
object.
This can be used to efficiently compute the digests of strings that
share a common initial substring.
:Return: A hash object of the same type
zError %d while copying MD4)r r �md4_copyr r r )r �cloner r r r �copy� s �zMD4Hash.copyc C s t |�S �N)r )r r r r r �new� s zMD4Hash.newr- )
�__name__�
__module__�__qualname__�__doc__r �
block_size�oidr r r# r) r, r. r r r r r D s
r Nc C s t � �| �S )a Return a fresh instance of the hash object.
:Parameters:
data : byte string/byte array/memoryview
The very first chunk of the message to hash.
It is equivalent to an early call to `MD4Hash.update()`.
Optional.
:Return: A `MD4Hash` object
)r r. )r r r r r. � s r. r- )r2 �Crypto.Util.py3compatr �Crypto.Util._raw_apir r r r r r r
r �objectr r. r r3 r r r r �<module> s $�
d