Exemplo n.º 1
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, handler=cls)
     if chk:
         # chk should be full des_crypt hash
         if not salt:
             # django 1.4 always uses empty salt field,
             # so extract salt from des_crypt hash <chk>
             salt = chk[:2]
         elif salt[:2] != chk[:2]:
             # django 1.0 stored 5 chars in salt field, and duplicated
             # the first two chars in <chk>. we keep the full salt,
             # but make sure the first two chars match as sanity check.
             raise uh.exc.MalformedHashError(
                 cls, "first two digits of salt and checksum must match")
         # in all cases, strip salt chars from <chk>
         chk = chk[2:]
     return cls(salt=salt, checksum=chk)
Exemplo n.º 2
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, handler=cls)
     if chk:
         # chk should be full des_crypt hash
         if not salt:
             # django 1.4 always uses empty salt field,
             # so extract salt from des_crypt hash <chk>
             salt = chk[:2]
         elif salt[:2] != chk[:2]:
             # django 1.0 stored 5 chars in salt field, and duplicated
             # the first two chars in <chk>. we keep the full salt,
             # but make sure the first two chars match as sanity check.
             raise uh.exc.MalformedHashError(cls,
                 "first two digits of salt and checksum must match")
         # in all cases, strip salt chars from <chk>
         chk = chk[2:]
     return cls(salt=salt, checksum=chk)
Exemplo n.º 3
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, handler=cls)
     return cls(salt=salt, checksum=chk)
Exemplo n.º 4
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, handler=cls)
     return cls(salt=salt, checksum=chk)
Exemplo n.º 5
0
    def from_string(cls, hash, **context):
        """Parse instance from configuration string in Modular Crypt Format."""
        salt, checksum = parse_mc2(hash, cls.ident, handler=cls)

        return cls(salt=salt, checksum=checksum)
Exemplo n.º 6
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, cls.name)
     return cls(salt=salt, checksum=chk, strict=bool(chk))
Exemplo n.º 7
0
 def from_string(cls, _hash, **context):
     salt, chk = parse_mc2(_hash, cls.ident, handler=cls)
     return cls(salt=salt, checksum=chk)
Exemplo n.º 8
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, cls.ident, cls.name)
     return cls(salt=salt, checksum=chk, strict=bool(chk))
Exemplo n.º 9
0
 def from_string(cls, hash):
     salt, chk = uh.parse_mc2(hash, u'')
     if chk is None:
         raise ValueError('missing checksum')
     return cls(salt=salt, checksum=chk)