ó
³Ebc           @   sÔ   d  d l  Z  d  d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l	 m
 Z
 d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿNi   (   t   constant_time_compare(   t   _base64_alphabet(   t   base64_decode(   t   base64_encode(   t
   want_bytes(   t   BadSignaturet   SigningAlgorithmc           B   s    e  Z d  Z d „  Z d „  Z RS(   sg   Subclasses must implement :meth:`get_signature` to provide
    signature generation functionality.
    c         C   s   t  ƒ  ‚ d S(   s2   Returns the signature for the given key and value.N(   t   NotImplementedError(   t   selft   keyt   value(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   get_signature   s    c         C   s   t  | |  j | | ƒ ƒ S(   sM   Verifies the given signature matches the expected
        signature.
        (   R    R   (   R   R	   R
   t   sig(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   verify_signature   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR      s   	t   NoneAlgorithmc           B   s   e  Z d  Z d „  Z RS(   s`   Provides an algorithm that does not perform any signing and
    returns an empty signature.
    c         C   s   d S(   Nt    (    (   R   R	   R
   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   !   s    (   R   R   R   R   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR      s   t   HMACAlgorithmc           B   s2   e  Z d  Z e e j ƒ Z d d „ Z d „  Z	 RS(   s*   Provides signature generation using HMACs.c         C   s%   | d  k r |  j } n  | |  _ d  S(   N(   t   Nonet   default_digest_methodt   digest_method(   R   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   __init__-   s    c         C   s(   t  j | d | d |  j ƒ} | j ƒ  S(   Nt   msgt	   digestmod(   t   hmact   newR   t   digest(   R   R	   R
   t   mac(    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   2   s    N(
   R   R   R   t   staticmethodt   hashlibt   sha1R   R   R   R   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   %   s   t   Signerc           B   sq   e  Z d  Z e e j ƒ Z d Z d
 d d
 d
 d
 d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d	 „  Z RS(   sè  This class can sign and unsign bytes, validating the signature
    provided.

    Salt can be used to namespace the hash, so that a signed string is
    only valid for a given namespace. Leaving this at the default value
    or re-using a salt value across different parts of your application
    where the same signed value in one part can mean something different
    in another part is a security risk.

    See :ref:`the-salt` for an example of what the salt is doing and how
    you can utilize it.

    .. versionadded:: 0.14
        ``key_derivation`` and ``digest_method`` were added as arguments
        to the class constructor.

    .. versionadded:: 0.18
        ``algorithm`` was added as an argument to the class constructor.
    s   django-concatt   .c         C   sÄ   t  | ƒ |  _ t  | ƒ |  _ |  j t k r< t d ƒ ‚ n  | d  k rN d n | |  _ | d  k ro |  j } n  | |  _ | d  k r |  j	 } n  | |  _
 | d  k r· t |  j
 ƒ } n  | |  _ d  S(   Ns‹   The given separator cannot be used because it may be contained in the signature itself. Alphanumeric characters and `-_=` must not be used.s   itsdangerous.Signer(   R   t
   secret_keyt   sepR   t
   ValueErrorR   t   saltt   default_key_derivationt   key_derivationR   R   R   t	   algorithm(   R   R#   R&   R$   R(   R   R)   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   [   s    			c         C   sÌ   t  |  j ƒ } |  j d k r8 |  j | |  j ƒ j ƒ  S|  j d k re |  j | d |  j ƒ j ƒ  S|  j d k r¦ t j |  j d |  j ƒ} | j | ƒ | j ƒ  S|  j d k r¼ |  j St	 d ƒ ‚ d S(	   s+  This method is called to derive the key. The default key
        derivation choices can be overridden here. Key derivation is not
        intended to be used as a security method to make a complex key
        out of a short password. Instead you should use large random
        secret keys.
        t   concats   django-concatt   signerR   R   t   nones   Unknown key derivation methodN(
   R   R&   R(   R   R#   R   R   R   t   updatet	   TypeError(   R   R&   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt
   derive_keyw   s    
c         C   s7   t  | ƒ } |  j ƒ  } |  j j | | ƒ } t | ƒ S(   s*   Returns the signature for the given value.(   R   R/   R)   R   R   (   R   R
   R	   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   Œ   s    c         C   s$   t  | ƒ t  |  j ƒ |  j | ƒ S(   s   Signs the given string.(   R   R$   R   (   R   R
   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   sign“   s    c         C   sG   |  j  ƒ  } y t | ƒ } Wn t k
 r0 t SX|  j j | | | ƒ S(   s+   Verifies the signature for the given value.(   R/   R   t	   Exceptiont   FalseR)   R   (   R   R
   R   R	   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR   —   s    c         C   s…   t  | ƒ } t  |  j ƒ } | | k r= t d |  j ƒ ‚ n  | j | d ƒ \ } } |  j | | ƒ rk | St d | d | ƒ‚ d S(   s   Unsigns the given string.s   No %r found in valuei   s   Signature %r does not matcht   payloadN(   R   R$   R   t   rsplitR   (   R   t   signed_valueR$   R
   R   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   unsign    s    c         C   s.   y |  j  | ƒ t SWn t k
 r) t SXd S(   sn   Only validates the given signed value. Returns ``True`` if
        the signature exists and is valid.
        N(   R6   t   TrueR   R2   (   R   R5   (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   validate«   s
    N(   R   R   R   R   R   R    R   R'   R   R   R/   R   R0   R   R6   R8   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyR!   7   s   						(   R   R   t   _compatR    t   encodingR   R   R   R   t   excR   t   objectR   R   R   R!   (    (    (    sk   /var/www/html/facial-emotion-detection-webapp-main/flask/lib/python2.7/site-packages/itsdangerous/signer.pyt   <module>   s   	