a fŸWc¼ã@s dZddlmZddlZddlZe e¡Zddlm Z ddl m Z ddl m Z mZmZmZmZddlmmZddgZGd d„dejƒZGd d „d ejƒZdS) a8passlib.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Úmysql323Zmysq41c@s2eZdZdZdZdZejZe dd„ƒZ dd„Z dS)r aThis 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. écCs| ¡S©N)Úlower©ÚclsÚhash©rú:/usr/lib/python3.9/site-packages/passlib/handlers/mysql.pyÚ _norm_hash>szmysql323._norm_hashc Cs t|tƒr| d¡}d}d}d}d}d}d}|D]V}||vr>q0t|ƒ} ||d@|| |d >|@N}||d >|A|@}|| |@}q0td ƒ||@||@fS) Núutf-8lÿÿiÿÿÿs i5W0PiqV4éé?éz%08x%08x)Ú isinstancerÚencoderr) ÚselfÚsecretZMASK_32ZMASK_31ZWHITEZnr1Znr2ÚaddÚcÚtmprrrÚ_calc_checksumBs    zmysql323._calc_checksumN) Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚnameÚ checksum_sizeÚuhÚ HEX_CHARSÚchecksum_charsÚ classmethodrrrrrrr -s  c@s:eZdZdZdZedƒZejZ dZ e dd„ƒZ dd„Z dS) Úmysql41aThis 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. Ú*é(cCs| ¡Sr )Úupperrrrrrpszmysql41._norm_hashcCs0t|tƒr| d¡}ttt|ƒ ¡ƒ ¡ƒ ¡S)Nr)rrrr rÚdigestÚ hexdigestr-)rrrrrrts  zmysql41._calc_checksumN)r r!r"r#r$rZ _hash_prefixr&r'r(r%r)rrrrrrr*^s  r*)r#ZhashlibrÚreZloggingZ getLoggerr ÚlogÚwarningsrZ passlib.utilsrZpasslib.utils.compatrrrrr Zpasslib.utils.handlersZutilsÚhandlersr&Ú__all__Z StaticHandlerr r*rrrrÚs   þ1