Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
 def helper():
     hash = handler.hash(SECRET)
     handler.verify(SECRET, hash)
     handler.verify(OTHER, hash)
Ejemplo n.º 4
0
 def helper():
     hash = handler.encrypt(SECRET, **kwds)
     handler.verify(SECRET, hash)
     handler.verify(OTHER, hash)
Ejemplo n.º 5
0
 def helper():
     hash = handler.encrypt(SECRET, salt='....')
     handler.verify(SECRET, hash)
     handler.verify(OTHER, hash)
Ejemplo n.º 6
0
 def helper():
     hash = handler.encrypt(SECRET, **kwds)
     handler.verify(SECRET, hash)
     handler.verify(OTHER, hash)
Ejemplo n.º 7
0
 def helper():
     hash = handler.encrypt(SECRET, salt='....')
     handler.verify(SECRET, hash)
     handler.verify(OTHER, hash)