a b @sNdZddlZddlZejjZejjZejj Z ejj Z ejj ZejjZejjZejjZejjZejjZejjZejjZejjZejjZ ejj!Z"ejj#Z$ej%j&fe'ej%j(e'dddZ)ej%j&fe'ej%j(e'dddZ*edddej%j&fe'e+e'e'e'ej%j(e'd d d Z,e,Z-dej%j&fe'e'ej%j(e'd d dZ.e.Z/dej%j&fe'e'ej%j(e'd ddZ0dS)z The :mod:`nacl.hash` module exposes one-shot interfaces for libsodium selected hash primitives and the constants needed for their usage. N)messageencoderreturncCs|tj|S)z Hashes ``message`` with SHA256. :param message: The message to hash. :type message: bytes :param encoder: A class that is able to encode the hashed message. :returns: The hashed message. :rtype: bytes )encodenaclbindingsZcrypto_hash_sha256rrr 0/tmp/pip-target-98j97qn4/lib/python/nacl/hash.pysha256>s r cCs|tj|S)z Hashes ``message`` with SHA512. :param message: The message to hash. :type message: bytes :param encoder: A class that is able to encode the hashed message. :returns: The hashed message. :rtype: bytes )rrrZcrypto_hash_sha512rr r r sha512Ms r )data digest_sizekeysaltpersonrrcCst|||||d}||S)a Hashes ``data`` with blake2b. :param data: the digest input byte sequence :type data: bytes :param digest_size: the requested digest size; must be at most :const:`BLAKE2B_BYTES_MAX`; the default digest size is :const:`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 :data:`~nacl.hash.BLAKE2B_KEYBYTES_MAX` long :type key: bytes :param salt: an initialization salt at most :const:`BLAKE2B_SALTBYTES` long; it will be zero-padded if needed :type salt: bytes :param person: a personalization string at most :const:`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 :returns: The hashed message. :rtype: bytes )rrrr) _b2b_hashr)rrrrrrdigestr r r blake2b\s# r)rrrrcCst||}||S)a Computes a keyed MAC of ``message`` using the short-input-optimized siphash-2-4 construction. :param message: The message to hash. :type message: bytes :param key: the message authentication key for the siphash MAC construct :type key: bytes(:const:`SIPHASH_KEYBYTES`) :param encoder: A class that is able to encode the hashed message. :returns: The hashed message. :rtype: bytes(:const:`SIPHASH_BYTES`) ) _sip_hashrrrrrr r r siphash24s rcCst||}||S)aE Computes a keyed MAC of ``message`` using the 128 bit variant of the siphash-2-4 construction. :param message: The message to hash. :type message: bytes :param key: the message authentication key for the siphash MAC construct :type key: bytes(:const:`SIPHASHX_KEYBYTES`) :param encoder: A class that is able to encode the hashed message. :returns: The hashed message. :rtype: bytes(:const:`SIPHASHX_BYTES`) :raises nacl.exceptions.UnavailableError: If called when using a minimal build of libsodium. .. versionadded:: 1.2 ) _sip_hashxrrr r r siphashx24s r)1__doc__Z nacl.bindingsrZ nacl.encodingrZcrypto_generichash_BYTESZ BLAKE2B_BYTESZcrypto_generichash_BYTES_MINZBLAKE2B_BYTES_MINZcrypto_generichash_BYTES_MAXZBLAKE2B_BYTES_MAXZcrypto_generichash_KEYBYTESZBLAKE2B_KEYBYTESZcrypto_generichash_KEYBYTES_MINZBLAKE2B_KEYBYTES_MINZcrypto_generichash_KEYBYTES_MAXZBLAKE2B_KEYBYTES_MAXZcrypto_generichash_SALTBYTESZBLAKE2B_SALTBYTESZ crypto_generichash_PERSONALBYTESZBLAKE2B_PERSONALBYTESZ crypto_shorthash_siphash24_BYTESZ SIPHASH_BYTESZ#crypto_shorthash_siphash24_KEYBYTESZSIPHASH_KEYBYTESZhas_crypto_shorthash_siphashx24ZSIPHASHX_AVAILABLEZ!crypto_shorthash_siphashx24_BYTESZSIPHASHX_BYTESZ$crypto_shorthash_siphashx24_KEYBYTESZSIPHASHX_KEYBYTESZ(crypto_generichash_blake2b_salt_personalrZcrypto_shorthash_siphash24rZcrypto_shorthash_siphashx24rencodingZ HexEncoderbytesZEncoderr r intrZ generichashrZ shorthashrr r r r sx   )