3
X                 @   s   d dl mZmZmZ d dlZd dlZejjZ	ejj
ZejjZejjZejjZejjZejjZejjZejjZejjZejjZejjZej j!fddZ"ej j!fddZ#e	dddej j!fdd	Z$e$Z%dej j!fd
dZ&e&Z'dS )    )absolute_importdivisionprint_functionNc             C   s   |j tjj| S )N)encodenaclbindingsZcrypto_hash_sha256)messageencoder r
   +/usr/lib/python3/dist-packages/nacl/hash.pysha256%   s    r   c             C   s   |j tjj| S )N)r   r   r   Zcrypto_hash_sha512)r   r	   r
   r
   r   sha512)   s    r       c             C   s   t | ||||d}|j|S )a  
    One-shot blake2b digest

    :param data: the digest input byte sequence
    :type data: bytes
    :param digest_size: the requested digest size; must be at most
                        :py:data:`.BLAKE2B_BYTES_MAX`;
                        the default digest size is :py:data:`.BLAKE2B_BYTES`
    :type digest_size: int
    :param key: the key to be set for keyed MAC/PRF usage; if set, the key
                must be at most :py:data:`.BLAKE2B_KEYBYTES_MAX` long
    :type key: bytes
    :param salt: an initialization salt at most
                 :py:data:`.BLAKE2B_SALTBYTES` long; it will be zero-padded
                 if needed
    :type salt: bytes
    :param person: a personalization string at most
                     :py:data:`.BLAKE2B_PERSONALBYTES` long; it will be
                     zero-padded if needed
    :type person: bytes
    :param encoder: the encoder to use on returned digest
    :type encoder: class
    :return: encoded bytes data
    :rtype: the return type of the choosen encoder
    )digest_sizekeysaltperson)	_b2b_hashr   )datar   r   r   r   r	   digestr
   r
   r   blake2b-   s    
r   c             C   s   t | |}|j|S )a   
    Computes a keyed MAC of ``message`` using siphash-2-4

    :param message: The message to hash.
    :type message: bytes
    :param key: the message authentication key for the siphash MAC construct
    :type key: bytes(:py:data:`.SIPHASH_KEYBYTES`)
    :param encoder: A class that is able to encode the hashed message.
    :return: The hashed message.
    :rtype: bytes(:py:data:`.SIPHASH_BYTES`)

    The :py:func:`.siphash24` construct is also exposed with the
    :py:func:`.shorthash` name for compatibility with libsodium names.
    )	_sip_hashr   )r   r   r	   r   r
   r
   r   	siphash24R   s    
r   )(Z
__future__r   r   r   Znacl.bindingsr   Znacl.encodingr   Zcrypto_generichash_BYTESZBLAKE2B_BYTESZcrypto_generichash_BYTES_MINZBLAKE2B_BYTES_MINZcrypto_generichash_BYTES_MAXZBLAKE2B_BYTES_MAXZcrypto_generichash_KEYBYTESZBLAKE2B_KEYBYTESZcrypto_generichash_KEYBYTES_MINZBLAKE2B_KEYBYTES_MINZcrypto_generichash_KEYBYTES_MAXZBLAKE2B_KEYBYTES_MAXZcrypto_generichash_SALTBYTESZBLAKE2B_SALTBYTESZ crypto_generichash_PERSONALBYTESZBLAKE2B_PERSONALBYTESZ crypto_shorthash_siphash24_BYTESZSIPHASH_BYTESZ#crypto_shorthash_siphash24_KEYBYTESZSIPHASH_KEYBYTESZ(crypto_generichash_blake2b_salt_personalr   Zcrypto_shorthash_siphash24r   encodingZ
HexEncoderr   r   r   Zgenerichashr   Z	shorthashr
   r
   r
   r   <module>   s,    