U ê üeÝ ã@s<dZddlZddlZddlmZmZmZGdd„deƒZdS)z.Implementation of MySQL Authentication Plugin.éNé)ÚPY3Ú UNICODE_TYPESÚhexlifyc@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚMySQL41AuthPlugincCs$||_t|tƒr| d¡n||_dS)Nzutf-8)Ú _usernameÚ isinstancerÚencodeÚ _password)ÚselfÚusernameÚpassword©rúj/opt/hc_python/lib64/python3.8/site-packages/../../../lib/python3.8/site-packages/mysqlx/authentication.pyÚ__init__!s ÿ ÿzMySQL41AuthPlugin.__init__cCsdS)NzMySQL 4.1 Authentication Pluginr©r rrrÚname&szMySQL41AuthPlugin.namecCsdS)NZMYSQL41rrrrrÚ auth_name)szMySQL41AuthPlugin.auth_namecCs<trdd„t||ƒDƒ}ndd„t||ƒDƒ}tjd|žŽS)zmEncrypt/Decrypt function used for password encryption in authentication, using a simple XOR. cSsg|]\}}||A‘qSrr©Ú.0Úh1Úh2rrrÚ 1sz0MySQL41AuthPlugin.xor_string..cSs g|]\}}t|ƒt|ƒA‘qSr)Úordrrrrr3sÚ20B)r)rÚzipÚstructÚpack)r Zhash1Zhash2ZxoredrrrÚ xor_string,szMySQL41AuthPlugin.xor_stringcCsd|jrRt |j¡ ¡}t |¡ ¡}| |t ||¡ ¡¡}d d|jt|ƒ¡Sd d|j¡SdS)z-Hashing for MySQL 4.1 authentication z {0}{1}*{2}Úz{0}{1}N)r ÚhashlibÚsha1ÚdigestrÚformatrr)r ÚdatarrZ auth_responserrrÚbuild_authentication_response6sÿ ÿz/MySQL41AuthPlugin.build_authentication_responseN)Ú__name__Ú __module__Ú __qualname__rrrrr%rrrrr s  r) Ú__doc__r rÚcompatrrrÚobjectrrrrrÚs