
    =h                         d Z ddlZddlZddlmZ dZdeeef   defdZdeeef   d	eeef   d
eeef   defdZ	deeef   d	eeef   defdZ
deeef   d	eeef   deeef   fdZy)z!
Authentication related methods.
    N)Union)auth_crammd5_verifyauth_plain_encodeauth_login_encodevaluereturnc                 ^    t        | t        t        t        f      r| S | j	                  d      S )Nzutf-8)
isinstancebytes	bytearray
memoryviewencode)r   s    _/var/www/html/phonemate/phone_mate_backend/venv/lib/python3.12/site-packages/aiosmtplib/auth.py_ensure_bytesr      s'    %%J78<<      usernamepassword	challengec                    t        |       }t        |      }t        j                  |      }t        j                  ||d      }|dz   |j                         j                  d      z   }t        j                  |      }|S )z
    CRAM-MD5 auth uses the password as a shared secret to MD5 the server's
    response, and sends the username combined with that (base64 encoded).
    md5)msg	digestmod    ascii)r   base64	b64decodehmacnew	hexdigestr   	b64encode)	r   r   r   username_bytespassword_bytesdecoded_challenge
md5_digestverificationencoded_verifications	            r   r   r      sv     #8,N"8,N((3..?5QJ!D(:+?+?+A+H+H+QQL!++L9r   c                r    t        |       }t        |      }d|z   dz   |z   }t        j                  |      }|S )zG
    PLAIN auth base64 encodes the username and password together.
        r   r   r    )r   r   r!   r"   username_and_passwordencodeds         r   r   r   )   sC     #8,N"8,N!N2U:^K45GNr   c                    t        |       }t        |      }t        j                  |      }t        j                  |      }||fS )z]
    LOGIN auth base64 encodes the username and password and sends them
    in sequence.
    r)   )r   r   r!   r"   encoded_usernameencoded_passwords         r   r   r   :   sF     #8,N"8,N''7''7---r   )__doc__r   r   typingr   __all__strr   r   r   r   tupler    r   r   <module>r5      s       L!sEz* !u ! CJ CJ  S%Z  
  *CJCJ 	".CJ.CJ. 5%<	.r   