
    it              
           S SK r S SKrS SKJr  S SKJr  S SKJr  S SKJr  \R                  " \
5      rSS\S\\   S\4S	 jjrSS
\S\S\\\\4      S\4S jjrg)    N)blake2b)gethostname)Optional)Unionhashpepperreturnc                 2    [        5       nU(       d  [        R                  S5        UR	                  S5      (       a  UR                  SS5      S   nU (       a  [        S	X!5      nU$ ! [         a$  n[        R                  SU 35        Sn SnANiSnAff = f)
z
Return the hostname for the current machine.

Args:
    hash: Whether to hash the hostname.
    pepper: Optional pepper for additional security (base64 encoded)

Returns:
    The hostname.
z*socket.gethostname returned an empty valuez(socket.gethostname raised an exception:  Nz.local.   r   hostname)r   loggerinfo	Exceptionendswithrsplithash_string)r   r   r   es       3lib/python3.13/site-packages/anaconda_auth/utils.pyget_hostnamer      s    =KKDE
 ""??3*1-z8<O  >qcBCs   &A( (
B2BBwhatsc                 h   [        U[        5      (       a  UR                  S5      nU=(       d    SS[        R                   nU R                  S5      n[        UR                  S5      SX2S9nUR                  5       n[        R                  " U5      R                  S5      R                  S5      nU$ )z
Return the hashed string for the current machine.

Args:
    what: The what to hash (example: "hostname").
    s: The string to hash.
    pepper: Optional pepper for additional security (base64 encoded)

Returns:
    Hashed string
zutf-8    N   )digest_sizepersonsalt   =ascii)

isinstancestrencoder   	SALT_SIZEdigestbase64urlsafe_b64encodestripdecode)r   r   r   r   hfuncdataresults          r   r   r   &   s     &#w'm0w001F[[!FAHHW%2fRE<<>D%%d+11$7>>wGFMr   )FN)N)r'   logginghashlibr   socketr   typingr   r   	getLogger__name__r   boolr#   r   bytesr    r   r   <module>r7      su         			8	$t Xc] c 6c c 8E#u*4E+F RU r   