
     h                         d Z ddlmZ ddlZddlZ ej
                  e      Zddlm	Z	 ddl
mZ ddlmZmZmZmZmZ ddlmc mZ ddgZ G d	 dej.                        Z G d
 dej.                        Zy)a8  passlib.handlers.mysql

MySQL 3.2.3 / OLD_PASSWORD()

    This implements Mysql's OLD_PASSWORD algorithm, introduced in version 3.2.3, deprecated in version 4.1.

    See :mod:`passlib.handlers.mysql_41` for the new algorithm was put in place in version 4.1

    This algorithm is known to be very insecure, and should only be used to verify existing password hashes.

    http://djangosnippets.org/snippets/1508/

MySQL 4.1.1 / NEW PASSWORD
    This implements Mysql new PASSWORD algorithm, introduced in version 4.1.

    This function is unsalted, and therefore not very secure against rainbow attacks.
    It should only be used when dealing with mysql passwords,
    for all other purposes, you should use a salted hash function.

    Description taken from http://dev.mysql.com/doc/refman/6.0/en/password-hashing.html
    )sha1N)warn)to_native_str)bascii_to_strunicodeubyte_elem_valuestr_to_uasciimysql323mysq41c                   F    e Zd ZdZd ZdZej                  Ze	d        Z
d Zy)r   a  This class implements the MySQL 3.2.3 password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.
       c                 "    |j                         S N)lowerclshashs     X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/passlib/handlers/mysql.py
_norm_hashzmysql323._norm_hash>       zz|    c                    t        |t              r|j                  d      }d}d}d}d}d}d}|D ]?  }||v rt        |      }	||dz  |z   |	z  |d	z  z   |z  z  }||d	z  |z  z   |z  }||	z   |z  }A t	        d
      ||z  ||z  fz  S )Nutf-8l    is    	i5W0PiqV4   ?      z%08x%08x)
isinstancer   encoder	   r   )
selfsecretMASK_32MASK_31WHITEnr1nr2addctmps
             r   _calc_checksumzmysql323._calc_checksumB   s    fg&]]7+F 	&AEz!!$CsRxnc)cQh77BBCS()W4Cs7g%C	& }gsW}===r   N)__name__
__module____qualname____doc__namechecksum_sizeuh	HEX_CHARSchecksum_charsclassmethodr   r*    r   r   r   r   -   s5     DM\\N
  >r   c                   V    e Zd ZdZd Z ed      Zej                  Z	dZ
ed        Zd Zy)mysql41a  This class implements the MySQL 4.1 password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.
    *(   c                 "    |j                         S r   )upperr   s     r   r   zmysql41._norm_hashp   r   r   c                     t        |t              r|j                  d      }t        t	        t	        |      j                               j                               j                         S )Nr   )r   r   r   r
   r   digest	hexdigestr;   )r    r!   s     r   r*   zmysql41._calc_checksumt   sI    fg&]]7+FT$v,"5"5"78BBDEKKMMr   N)r+   r,   r-   r.   r/   r   _hash_prefixr1   r2   r3   r0   r4   r   r*   r5   r   r   r7   r7   ^   s?     DS6L\\NM
  Nr   r7   )r.   hashlibr   relogging	getLoggerr+   logwarningsr   passlib.utilsr   passlib.utils.compatr   r   r   r	   r
   passlib.utils.handlersutilshandlersr1   __all__StaticHandlerr   r7   r5   r   r   <module>rM      sw   2  	 'g''1  (@ @ # # (>r (>bNb Nr   