
    N.h	                     B    d Z ddlZddlZddlmZmZmZ  G d de      Zy)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y)MySQL41AuthPluginc                 n    || _         t        |t              r|j                  d      | _        y || _        y )Nzutf-8)	_username
isinstancer   encode	_password)selfusernamepasswords      i/var/www/html/School_Mangement_New/src/backend/venv/lib/python3.12/site-packages/mysqlx/authentication.py__init__zMySQL41AuthPlugin.__init__!   s/    !(M2 "18@ 	    c                      y)NzMySQL 4.1 Authentication Plugin r   s    r   namezMySQL41AuthPlugin.name&   s    0r   c                      y)NMYSQL41r   r   s    r   	auth_namezMySQL41AuthPlugin.auth_name)   s    r   c                     t         r"t        ||      D cg c]
  \  }}||z   }}}n3t        ||      D cg c]  \  }}t        |      t        |      z   }}}t        j                  dg| S c c}}w c c}}w )zmEncrypt/Decrypt function used for password encryption in
        authentication, using a simple XOR.
        20B)r   zipordstructpack)r   hash1hash2h1h2xoreds         r   
xor_stringzMySQL41AuthPlugin.xor_string,   sq     -0->?"bR"W?E?7:5%7HI8BSWs2w&IEI{{5)5)) @Is
   A2!A8c                    | j                   rt        j                  | j                         j                         }t        j                  |      j                         }| j	                  |t        j                  ||z         j                               }dj                  d| j                  t        |            S dj                  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     >>dnn-446Bb!((*B OOGLL+2246M%,,R-4]-CE E  &&r4>>::r   N)__name__
__module____qualname__r   r   r   r&   r/   r   r   r   r   r       s    A
1*;r   r   )	__doc__r)   r   compatr   r   r   objectr   r   r   r   <module>r6      s"   0 5   / /!; !;r   