Example #1
0
    def _calc_checksum(self, secret):
        cls = self.__class__
        wrapper_cls = cls.__cc_compat_hack
        if wrapper_cls is None:

            def inner(self, secret):
                raise NotImplementedError(
                    '%s must implement _calc_checksum()' % (cls, ))

            wrapper_cls = cls.__cc_compat_hack = type(
                cls.__name__ + '_wrapper', (cls, ),
                dict(_calc_checksum=inner, __module__=cls.__module__))
        context = dict((k, getattr(self, k)) for k in self.context_kwds)
        try:
            hash = wrapper_cls.genhash(secret, None, **context)
        except TypeError as err:
            if str(err) == 'config must be string':
                raise NotImplementedError(
                    '%s must implement _calc_checksum()' % (cls, ))
            else:
                raise

        warn(
            '%r should be updated to implement StaticHandler._calc_checksum() instead of StaticHandler.genhash(), support for the latter style will be removed in Passlib 1.8'
            % cls, DeprecationWarning)
        return str_to_uascii(hash)
Example #2
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     data = self.salt.encode('ascii') + secret + self.salt.encode('ascii')
     return str_to_uascii(hashlib.sha1(data).hexdigest())
Example #3
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     data = 'boblious' + secret
     return str_to_uascii(hashlib.sha1(data).hexdigest())
Example #4
0
 def _calc_checksum(self, secret):
     time.sleep(self.delay)
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     return str_to_uascii(hashlib.sha1('prefix' + secret).hexdigest())
Example #5
0
 def _calc_checksum(self, secret):
     from hashlib import md5
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     return str_to_uascii(md5(secret).hexdigest())
Example #6
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     chk = sha1(secret + unhexlify(self.salt.encode('ascii'))).hexdigest()
     return str_to_uascii(chk).upper()
Example #7
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     user = to_bytes(self.user, 'utf-8', param='user')
     return str_to_uascii(md5(secret + user).hexdigest())
Example #8
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     return str_to_uascii(sha1(sha1(secret).digest()).hexdigest()).upper()
Example #9
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     return str_to_uascii(self._hash_func(secret).hexdigest())
Example #10
0
 def _calc_checksum(self, secret):
     if isinstance(secret, unicode):
         secret = secret.encode('utf-8')
     return str_to_uascii(md5(self.salt.encode('ascii') + secret).hexdigest())
Example #11
0
 def _calc_checksum_raw(self, secret):
     secret, ident = self._prepare_digest_args(secret)
     config = self._get_config(ident)
     hash = _pybcrypt.hashpw(secret, config)
     return str_to_uascii(hash[-31:])
Example #12
0
 def _calc_checksum(self, secret):
     secret, ident = self._prepare_digest_args(secret)
     config = self._get_config(ident)
     hash = _bcryptor.engine.Engine(False).hash_key(secret, config)
     return str_to_uascii(hash[-31:])