2626 ProgrammingError )
2727
2828from pymysql .connections import TEXT_TYPES , MAX_PACKET_LEN , DEFAULT_CHARSET
29- # from pymysql.connections import dump_packet
30- from pymysql .connections import _scramble
31- from pymysql .connections import _scramble_323
29+ from pymysql .connections import _auth
30+
3231from pymysql .connections import pack_int24
3332
3433from pymysql .connections import MysqlPacket
@@ -687,7 +686,7 @@ async def _request_authentication(self):
687686 auth_plugin = self ._server_auth_plugin
688687
689688 if auth_plugin in ('' , 'mysql_native_password' ):
690- authresp = _scramble (self ._password . encode ( 'latin1' ) , self .salt )
689+ authresp = _auth . scramble_native_password (self ._password , self .salt )
691690 elif auth_plugin in ('' , 'mysql_clear_password' ):
692691 authresp = self ._password .encode ('latin1' ) + b'\0 '
693692
@@ -731,8 +730,7 @@ async def _request_authentication(self):
731730 plugin_name , auth_packet )
732731 else :
733732 # send legacy handshake
734- data = _scramble_323 (self ._password .encode ('latin1' ),
735- self .salt ) + b'\0 '
733+ data = _auth .scramble_old_password (self ._password , auth_packet .read_all ()) + b'\0 '
736734 self .write_packet (data )
737735 auth_packet = await self ._read_packet ()
738736
@@ -741,13 +739,11 @@ async def _process_auth(self, plugin_name, auth_packet):
741739 # https://dev.mysql.com/doc/internals/en/
742740 # secure-password-authentication.html#packet-Authentication::
743741 # Native41
744- data = _scramble (self ._password .encode ('latin1' ),
745- auth_packet .read_all ())
742+ data = _auth .scramble_native_password (self ._password , auth_packet .read_all ())
746743 elif plugin_name == b"mysql_old_password" :
747744 # https://dev.mysql.com/doc/internals/en/
748745 # old-password-authentication.html
749- data = _scramble_323 (self ._password .encode ('latin1' ),
750- auth_packet .read_all ()) + b'\0 '
746+ data = _auth .scramble_old_password (self ._password , auth_packet .read_all ()) + b'\0 '
751747 elif plugin_name == b"mysql_clear_password" :
752748 # https://dev.mysql.com/doc/internals/en/
753749 # clear-text-authentication.html
0 commit comments