def verify_password(plaintext, ciphertext): ''' 对明文密码和密文密码进行校验 :param str plaintext: 明文密码 :param str ciphertext: 密文密码 :return: 密码是否正确 :rtype: bool ''' if ciphertext.startswith('{SSHA}'): return ldap_salted_sha1.verify(plaintext, ciphertext) if ciphertext.startswith('{SMD5}'): return ldap_salted_md5.verify(plaintext, ciphertext) if ciphertext.startswith('{MD5}'): return ldap_md5.verify(plaintext, ciphertext) if ciphertext.startswith('{SHA}'): return ldap_sha1.verify(plaintext, ciphertext) return False
def verify_password(self, plaintext, ciphertext): """ verify password. """ if plaintext is None or ciphertext is None: return False self.valid_encryption() if ciphertext.startswith('{SSHA}'): return ldap_salted_sha1.verify(plaintext, ciphertext) if ciphertext.startswith('{SMD5}'): return ldap_salted_md5.verify(plaintext, ciphertext) if ciphertext.startswith('{MD5}'): return ldap_md5.verify(plaintext, ciphertext) if ciphertext.startswith('{SHA}'): return ldap_sha1.verify(plaintext, ciphertext) return False
def helper(): hash = handler.hash(SECRET) handler.verify(SECRET, hash) handler.verify(OTHER, hash)
def helper(): hash = handler.encrypt(SECRET, **kwds) handler.verify(SECRET, hash) handler.verify(OTHER, hash)
def helper(): hash = handler.encrypt(SECRET, salt='....') handler.verify(SECRET, hash) handler.verify(OTHER, hash)
def helper(): hash = handler.encrypt(SECRET, **kwds) handler.verify(SECRET, hash) handler.verify(OTHER, hash)
def helper(): hash = handler.encrypt(SECRET, salt='....') handler.verify(SECRET, hash) handler.verify(OTHER, hash)