%PDF- %PDF-
Direktori : /proc/self/root/lib/python2.7/site-packages/passlib/handlers/ |
Current File : //proc/self/root/lib/python2.7/site-packages/passlib/handlers/phpass.pyo |
� � 5Xc @ s� d Z d d l m Z d d l Z e j e � Z d d l m Z d d l m Z m Z m Z d d l j j Z d g Z d e j e j e j e j f d � � YZ d S( s� passlib.handlers.phpass - PHPass Portable Crypt phppass located - http://www.openwall.com/phpass/ algorithm described - http://www.openwall.com/articles/PHP-Users-Passwords phpass context - blowfish, bsdi_crypt, phpass i����( t md5N( t h64( t ut uascii_to_strt unicodet phpassc B s� e Z d Z d Z d Z e j Z d Z Z e j Z d Z d Z d Z d Z e d � Z e d � e d � f Z i e d � e d � 6e d � e d � 6Z e d � � Z d � Z d � Z RS( s� This class implements the PHPass Portable Hash, and follows the :ref:`password-hash-api`. It supports a fixed-length salt, and a variable number of rounds. The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords: :type salt: str :param salt: Optional salt string. If not specified, one will be autogenerated (this is recommended). If specified, it must be 8 characters, drawn from the regexp range ``[./0-9A-Za-z]``. :type rounds: int :param rounds: Optional number of rounds to use. Defaults to 19, must be between 7 and 30, inclusive. This value is logarithmic, the actual number of iterations used will be :samp:`2**{rounds}`. :type ident: str :param ident: phpBB3 uses ``H`` instead of ``P`` for its identifier, this may be set to ``H`` in order to generate phpBB3 compatible hashes. it defaults to ``P``. :type relaxed: bool :param relaxed: By default, providing an invalid value for one of the other keywords will result in a :exc:`ValueError`. If ``relaxed=True``, and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning` will be issued instead. Correctable errors include ``rounds`` that are too small or too large, and ``salt`` strings that are too long. .. versionadded:: 1.6 R t saltt roundst identi i i i t log2s $P$s $H$t Pt Hc C so | j | � \ } } | d | d d !| d } } } | d | d t j | j d � � d | d | pk d � S( Ni i i R R t asciiR t checksum( t _parse_identR t decode_int6t encodet None( t clst hashR t dataR R t chk( ( s; /usr/lib/python2.7/site-packages/passlib/handlers/phpass.pyt from_string` s #c C sP t d � | j t j | j � j d � | j | j p? t d � f } t | � S( Ns %s%s%s%sR t ( R R R t encode_int6R t decodeR R R ( t selfR ( ( s; /usr/lib/python2.7/site-packages/passlib/handlers/phpass.pyt to_stringk s c C s� t | t � r! | j d � } n d | j >} t | j j d � | � j � } d } x0 | | k r� t | | � j � } | d 7} qY Wt j | � j d � S( Ns utf-8i R i ( t isinstanceR R R R R t digestR t encode_bytesR ( R t secrett real_roundst resultt r( ( s; /usr/lib/python2.7/site-packages/passlib/handlers/phpass.pyt _calc_checksumu s "( s salts roundss ident( t __name__t __module__t __doc__t namet setting_kwdst uht HASH64_CHARSt checksum_charst min_salt_sizet max_salt_sizet salt_charst default_roundst min_roundst max_roundst rounds_costR t default_identt ident_valuest ident_aliasest classmethodR R R# ( ( ( s; /usr/lib/python2.7/site-packages/passlib/handlers/phpass.pyR s " , ( R&