
    vd	                     J    d Z ddlZddlZddlmZmZmZ  G d de          ZdS )z.Implementation of MySQL Authentication Plugin.    N   )PY3UNICODE_TYPEShexlifyc                   ,    e Zd Zd Zd Zd Zd Zd ZdS )MySQL41AuthPluginc                 v    || _         t          |t                    r|                    d          n|| _        d S )Nzutf-8)	_username
isinstancer   encode	_password)selfusernamepasswords      Q/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/mysqlx/authentication.py__init__zMySQL41AuthPlugin.__init__!   s;    !(M22A1118@ 	    c                     dS )NzMySQL 4.1 Authentication Plugin r   s    r   namezMySQL41AuthPlugin.name&   s    00r   c                     dS )NMYSQL41r   r   s    r   	auth_namezMySQL41AuthPlugin.auth_name)   s    yr   c                     t           rd t          ||          D             }nd t          ||          D             }t          j        dg|R  S )zmEncrypt/Decrypt function used for password encryption in
        authentication, using a simple XOR.
        c                     g | ]
\  }}||z  S r   r   .0h1h2s      r   
<listcomp>z0MySQL41AuthPlugin.xor_string.<locals>.<listcomp>1   s     ???"bR"W???r   c                 R    g | ]$\  }}t          |          t          |          z  %S r   )ordr   s      r   r!   z0MySQL41AuthPlugin.xor_string.<locals>.<listcomp>3   s-    III8BSWWs2ww&IIIr   20B)r   zipstructpack)r   hash1hash2xoreds       r   
xor_stringzMySQL41AuthPlugin.xor_string,   sa      	J??S->->???EEIIs5%7H7HIIIE{5)5))))r   c                    | j         rt          j        | j                                                   }t          j        |                                          }|                     |t          j        ||z                                                       }d                    d| j        t          |                    S d                    d| j                  S )z-Hashing for MySQL 4.1 authentication
        z{0} {1} *{2}  z{0} {1} )r   hashlibsha1digestr+   formatr
   r   )r   datar   r    auth_responses        r   build_authentication_responsez/MySQL41AuthPlugin.build_authentication_response6   s     > 	;dn--4466Bb!!((**B OOGL++22446 6M%,,R-4]-C-CE E E  &&r4>:::r   N)__name__
__module____qualname__r   r   r   r+   r4   r   r   r   r   r       sb        A A A
1 1 1  * * *; ; ; ; ;r   r   )	__doc__r.   r&   compatr   r   r   objectr   r   r   r   <module>r;      sq   0 5 4   / / / / / / / / / /!; !; !; !; !; !; !; !; !; !;r   