U
    ֫[                     @   sp   d dl mZmZmZ d dlmZ d dlmZm	Z	 d dlm
Z
 e	 Ze	 Ze	 Ze	 Zdd Zdd ZdS )	    )absolute_importdivisionprint_functionN)ffilib)ensurec                 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 {0} bytesunsigned char[]r   ZraisingN)lenKEYBYTESexc
ValueErrorformatr   newBYTESr   crypto_shorthash_siphash24r   RuntimeErrorbufferdatakeyZdigestZrc r   @/usr/lib/python3/dist-packages/nacl/bindings/crypto_shorthash.pyr      s    	r   c                 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:`.XKEYBYTES` (16)
    :type key: bytes
    r   r	   r   r
   N)r   	XKEYBYTESr   r   r   r   r   XBYTESr   crypto_shorthash_siphashx24r   r   r   r   r   r   r   r   .   s    	r   )Z
__future__r   r   r   Znacl.exceptions
exceptionsr   Znacl._sodiumr   r   r   Z crypto_shorthash_siphash24_bytesr   Z#crypto_shorthash_siphash24_keybytesr   Z!crypto_shorthash_siphashx24_bytesr   Z$crypto_shorthash_siphashx24_keybytesr   r   r   r   r   r   r   <module>   s   