
    ܖi              	       
   U d Z dgZddlmZ ddlmZmZ ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  dZeeef   ed<    G d d      Zy)	zHash related factoriesHashTypeFactory   )UnknownHashTypeException)HashAlgorithmHashType)md5sha1sha256sha384sha512sha3_256sha3_384sha3_512_MAP_HASHLIBc                   0    e Zd ZdededefdZdedefdZy)r   hashlib_algcontentreturnc                     t         j                  |j                               }|t        d|      t	        ||      S )a  
        Attempts to convert a hashlib-algorithm to our internal model classes.

        Args:
             hashlib_alg:
                Hash algorithm - like it is used by `hashlib`.
                Example: `sha256`.

            content:
                Hash value.

        Raises:
            `UnknownHashTypeException` if the algorithm of hash cannot be determined.

        Returns:
            An instance of `HashType`.
        z!Unable to determine hash alg for algr   )r   getlowerr   r   )selfr   r   r   s       d/var/www/html/content-pipeline/venv/lib/python3.12/site-packages/cyclonedx/contrib/hash/factories.pyfrom_hashlib_algz HashTypeFactory.from_hashlib_alg.   sB    $ {0023;*-N{o+^__C11    composite_hashc           	      b   |j                  d      }|d   j                         }|dk(  r,t        t        j                  |d   j                               S |dd dk(  r2t        t        t        d|d	d
        |d   j                               S |dk(  r,t        t        j                  |d   j                               S |dd dk(  r2t        t        t        d|dd
        |d   j                               S |dd dk(  r2t        t        t        d|dd
        |d   j                               S |dd dk(  r2t        t        t        d|dd
        |d   j                               S |dd dk(  r,t        t        j                  |d   j                               S t        d|      )a,  
        Attempts to convert a string which includes both the Hash Algorithm and Hash Value and represent using our
        internal model classes.

        Args:
             composite_hash:
                Composite Hash string of the format `HASH_ALGORITHM`:`HASH_VALUE`.
                Example: `sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b`.

                Valid case insensitive prefixes are:
                `md5`, `sha1`, `sha256`, `sha384`, `sha512`, `blake2b256`, `blake2b384`, `blake2b512`,
                `blake2256`, `blake2384`, `blake2512`, `sha3-256`, `sha3-384`, `sha3-512`,
                `blake3`.

        Raises:
            `UnknownHashTypeException` if the type of hash cannot be determined.

        Returns:
            An instance of `HashType`.
        :    r      r      sha3SHA3_   Nr   r   shaSHA_   blake2bBLAKE2B_   blake2blake3z#Unable to determine hash type from )	splitr   r   r   MD5getattrSHA_1BLAKE3r   )r   r   partsalgorithm_prefixs       r   from_composite_strz"HashTypeFactory.from_composite_strE   s   * $$S) 8>>+u$!%%a(  a"f,MU3CAB3G2H+IJa(  '!''a(  a"e+MT2B122F1G+HIa(  a"i/MX6Fqr6J5K+LMa(  a"h.MX6Fqr6J5K+LMa(  a"h.!((a(  ')L^L^'_``r   N)__name__
__module____qualname__strr   r   r5    r   r   r   r   ,   s2    2C 2# 2( 2.<a <a <ar   N)__doc____all__exception.modelr   modelr   r   r/   r1   SHA_256SHA_384SHA_512SHA3_256SHA3_384SHA3_512r   dictr9   __annotations__r   r:   r   r   <module>rG      s   $ 
 7 , ###### &&&&&&*d3%& &Ua Uar   