U
    cc+
                     @   s   U d dl mZ d dlmZmZ d dl mZ eejZ	e
 Zeed< e Zeed< d Zd Ze	rpe Ze ZeeedddZeeedd	d
ZdS )    N)ffilib)ensureBYTESKEYBYTES)datakeyreturnc                 C   sb   t |tkrtdttdt}t	|| t | |}t
|dktjd t|tdd S )zCompute a fast, cryptographic quality, keyed hash of the input data

    :param data:
    :type data: bytes
    :param key: len(key) must be equal to
                :py:data:`.KEYBYTES` (16)
    :type key: bytes
    #Key length must be exactly {} bytesunsigned char[]r   ZraisingN)lenr   exc
ValueErrorformatr   newr   r   crypto_shorthash_siphash24r   RuntimeErrorbufferr   r   digestrc r   B/tmp/pip-unpacked-wheel-e6sdgn5m/nacl/bindings/crypto_shorthash.pyr   $   s    	r   c                 C   sr   t tdtjd t|tkr,tdtt	dt
}t|| t| |}t |dktjd t|t
dd S )aC  Compute a fast, cryptographic quality, keyed hash of the input data

    :param data:
    :type data: bytes
    :param key: len(key) must be equal to
                :py:data:`.XKEYBYTES` (16)
    :type key: bytes
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.
    zNot available in minimal buildr   r
   r   r   N)r   has_crypto_shorthash_siphashx24r   ZUnavailableErrorr   	XKEYBYTESr   r   r   r   XBYTESr   crypto_shorthash_siphashx24r   r   r   r   r   r   r   8   s    r   )Znacl.exceptions
exceptionsr   Znacl._sodiumr   r   r   boolZ&PYNACL_HAS_CRYPTO_SHORTHASH_SIPHASHX24r   Z crypto_shorthash_siphash24_bytesr   int__annotations__Z#crypto_shorthash_siphash24_keybytesr   r   r   Z!crypto_shorthash_siphashx24_bytesZ$crypto_shorthash_siphashx24_keybytesbytesr   r   r   r   r   r   <module>   s    