File: //home/arjun/projects/env/lib/python3.10/site-packages/pathlib_mate/hashes.pyc
�
�´ac @ s^ d d l Z d Z d d � Z d e d � Z d e d � Z d e d � Z d e d
� Z d S( i����Ni i s utf-8c C s) | � } | j | j | � � | j � S( su
Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
( t updatet encodet hexdigest( t textt hash_metht encodingt m( ( s pathlib_mate/hashes.pyt get_text_fingerprint s i c C s: | d k r t d � � n | d k r6 t d � � n | d k rW | | k rW | } n | � } t | d � �� } | r� d } x� t r� | | 7} | | k r� | | | } | r� | j | � } | j | � n Pq� | j | � } | j | � q� Wn3 x0 t r)| j | � } | sPn | j | � q� WWd QX| j � S( Ni s chunk_size cannot smaller than 0i s chunk_size cannot smaller than 1t rb( t
ValueErrort opent Truet readR R ( t abspathR t nbytest
chunk_sizeR t ft
have_readst nt data( ( s pathlib_mate/hashes.pyt get_file_fingerprint s4
c C s t | t j d | d | �S( s�
Return md5 hash value of a piece of a file
Estimate processing time on:
:param abspath: the absolute path to the file
:param nbytes: only has first N bytes of the file. if 0 or None,
hash all file
CPU = i7-4600U 2.10GHz - 2.70GHz, RAM = 8.00 GB
1 second can process 0.25GB data
- 0.59G - 2.43 sec
- 1.3G - 5.68 sec
- 1.9G - 7.72 sec
- 2.5G - 10.32 sec
- 3.9G - 16.0 sec
R R ( R t hashlibt md5( R
R R ( ( s pathlib_mate/hashes.pyt md5file3 s c C s t | t j d | d | �S( s�
Return sha256 hash value of a piece of a file
Estimate processing time on:
:param abspath: the absolute path to the file
:param nbytes: only has first N bytes of the file. if 0 or None,
hash all file
R R ( R R t sha256( R
R R ( ( s pathlib_mate/hashes.pyt
sha256fileI s
c C s t | t j d | d | �S( s�
Return sha512 hash value of a piece of a file
Estimate processing time on:
:param abspath: the absolute path to the file
:param nbytes: only has first N bytes of the file. if 0 or None,
hash all file
R R ( R R t sha512( R
R R ( ( s pathlib_mate/hashes.pyt
sha512fileV s
i@ ( R t DEFAULT_CHUNK_SIZER R R R R ( ( ( s pathlib_mate/hashes.pyt <module> s
!