def from_string(cls, hash): # NOTE: passlib deviation - forbidding zero-padded rounds rounds, salt, chk = uh.parse_mc3(hash, cls.ident, rounds_base=16, handler=cls) salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS) if chk: chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS) return cls(rounds=rounds, salt=salt, checksum=chk)
def from_string(cls, hash): rounds, salt, chk = uh.parse_mc3(hash, cls.ident, rounds_base=16, default_rounds=400, handler=cls) return cls(rounds=rounds, salt=salt, checksum=chk)
def from_string(cls, hash): rounds, salt, chk = uh.parse_mc3(hash, cls.ident, sep=u("."), handler=cls) salt = unhexlify(salt.encode("ascii")) if chk: chk = unhexlify(chk.encode("ascii")) return cls(rounds=rounds, salt=salt, checksum=chk)
def from_string(cls, hash): rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) if rounds.startswith("0"): raise ValueError("invalid sha1-crypt hash (zero-padded rounds)") return cls( rounds=int(rounds), salt=salt, checksum=chk, strict=bool(chk), )
def from_string(cls, hash): if not hash: raise ValueError("no hash specified") rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) if rounds.startswith("0"): #zero not allowed, nor left-padded with zeroes raise ValueError("invalid dlitz_pbkdf2_sha1 hash") rounds = int(rounds, 16) if rounds else 400 return cls( rounds=rounds, salt=salt, checksum=chk, strict=bool(chk), )
def from_string(cls, hash): if not hash: raise ValueError("no hash specified") rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) if rounds.startswith( "0"): #zero not allowed, nor left-padded with zeroes raise ValueError("invalid dlitz_pbkdf2_sha1 hash") rounds = int(rounds, 16) if rounds else 400 return cls( rounds=rounds, salt=salt, checksum=chk, strict=bool(chk), )
def from_string(cls, hash): if not hash: raise ValueError("no hash specified") rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) int_rounds = int(rounds) if rounds != unicode(int_rounds): #forbid zero padding, etc. raise ValueError("invalid %s hash" % (cls.name,)) raw_salt = adapted_b64_decode(salt.encode("ascii")) raw_chk = adapted_b64_decode(chk.encode("ascii")) if chk else None return cls( rounds=int_rounds, salt=raw_salt, checksum=raw_chk, strict=bool(raw_chk), )
def from_string(cls, hash): if not hash: raise ValueError("no hash specified") rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) int_rounds = int(rounds) if rounds != unicode(int_rounds): #forbid zero padding, etc. raise ValueError("invalid %s hash" % (cls.name, )) raw_salt = adapted_b64_decode(salt.encode("ascii")) raw_chk = adapted_b64_decode(chk.encode("ascii")) if chk else None return cls( rounds=int_rounds, salt=raw_salt, checksum=raw_chk, strict=bool(raw_chk), )
def from_string(cls, hash): if not hash: raise ValueError("no hash specified") rounds, salt, chk = uh.parse_mc3(hash, cls.ident, cls.name) if rounds.startswith("0"): #passlib deviation: forbidding #left-padded with zeroes raise ValueError("invalid cta_pbkdf2_sha1 hash") rounds = int(rounds, 16) salt = b64decode(salt.encode("ascii"), CTA_ALTCHARS) if chk: chk = b64decode(chk.encode("ascii"), CTA_ALTCHARS) return cls( rounds=rounds, salt=salt, checksum=chk, strict=bool(chk), )
def from_string(cls, hash): rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls) return cls(rounds=rounds, salt=salt, checksum=chk)
def from_string(cls, hash): rounds, salt, chk = uh.parse_mc3(hash, cls.ident, handler=cls) salt = ab64_decode(salt.encode("ascii")) if chk: chk = ab64_decode(chk.encode("ascii")) return cls(rounds=rounds, salt=salt, checksum=chk)