PHP 클래스 PassHash, dokuwiki

파일 보기 프로젝트 열기: splitbrain/dokuwiki 1 사용 예제들

공개 메소드들

메소드 설명
gen_salt ( integer $len = 32 ) : string Create a random salt
hash_apr1 ( string $clear, string $salt = null, string $magic = 'apr1' ) : string Password hashing method 'apr1'
hash_bcrypt ( string $clear, string $salt = null, integer $compute = 8 ) : string Passwordhashing method 'bcrypt'
hash_crypt ( string $clear, string $salt = null ) : string Password hashing method 'crypt'
hash_djangomd5 ( string $clear, string $salt = null ) : string Password hashing method 'djangomd5'
hash_djangopbkdf2 ( string $clear, string $salt = null, array $opts = [] ) : string Password hashing method 'djangopbkdf2'
hash_djangopbkdf2_sha1 ( string $clear, string $salt = null, array $opts = [] ) : string Alias for djangopbkdf2 defaulting to sha1 as hash algorithm
hash_djangopbkdf2_sha256 ( string $clear, string $salt = null, array $opts = [] ) : string Alias for djangopbkdf2 defaulting to sha256 as hash algorithm
hash_djangosha1 ( string $clear, string $salt = null ) : string Password hashing method 'djangosha1'
hash_hmd5 ( $clear, $salt = null, $magic = 'H', $compute = 8 ) Alias for hash_pmd5
hash_kmd5 ( string $clear, string $salt = null ) : string Password hashing method 'kmd5'
hash_lsmd5 ( string $clear, string $salt = null ) : string Password hashing method 'lsmd5'
hash_md5 ( string $clear ) : string Password hashing method 'md5'
hash_mediawiki ( string $clear, string $salt = null ) : string Password hashing method 'mediawiki'
hash_my411 ( string $clear ) : string Password hashing method 'my411'
hash_mysql ( string $clear ) : string Password hashing method 'mysql'
hash_pmd5 ( string $clear, string $salt = null, string $magic = 'P', integer $compute = 8 ) : string Password hashing method 'pmd5'
hash_sha1 ( string $clear ) : string Password hashing method 'sha1'
hash_sha512 ( string $clear, string $salt = null ) : string Password hashing method SHA512
hash_smd5 ( string $clear, string $salt = null ) : string Password hashing method 'smd5'
hash_ssha ( string $clear, string $salt = null ) : string Password hashing method 'ssha' as used by LDAP
hmac ( string $algo, string $data, string $key, boolean $raw_output = false ) : string Wraps around native hash_hmac() or reimplents it
init_salt ( &$salt, integer $len = 32, boolean $cut = true ) Initialize the passed variable with a salt if needed.
verify_hash ( string $clear, string $hash ) : boolean Verifies a cleartext password against a crypted hash

보호된 메소드들

메소드 설명
random ( integer $min, integer $max ) : integer Use DokuWiki's secure random generator if available

메소드 상세

gen_salt() 공개 메소드

Create a random salt
public gen_salt ( integer $len = 32 ) : string
$len integer The length of the salt
리턴 string

hash_apr1() 공개 메소드

Uses salted MD5 hashs. Salt is 8 bytes long. This is basically the same as smd1 above, but as used by Apache.
public hash_apr1 ( string $clear, string $salt = null, string $magic = 'apr1' ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$magic string The hash identifier (apr1 or 1)
리턴 string Hashed password

hash_bcrypt() 공개 메소드

Uses a modified blowfish algorithm called eksblowfish This method works on PHP 5.3+ only and will throw an exception if the needed crypt support isn't available A full hash should be given as salt (starting with $a2$) or this will break. When no salt is given, the iteration count can be set through the $compute variable.
public hash_bcrypt ( string $clear, string $salt = null, integer $compute = 8 ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$compute integer The iteration count (between 4 and 31)
리턴 string Hashed password

hash_crypt() 공개 메소드

Uses salted crypt hashs. Salt is 2 bytes long.
public hash_crypt ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_djangomd5() 공개 메소드

Uses salted MD5 hashs. Salt is 5 bytes long. This is used by the Django Python framework
public hash_djangomd5 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_djangopbkdf2() 공개 메소드

An algorithm and iteration count should be given in the opts array. Defaults to sha256 and 24000 iterations
public hash_djangopbkdf2 ( string $clear, string $salt = null, array $opts = [] ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$opts array ('algo' => hash algorithm, 'iter' => iterations)
리턴 string Hashed password

hash_djangopbkdf2_sha1() 공개 메소드

Alias for djangopbkdf2 defaulting to sha1 as hash algorithm
public hash_djangopbkdf2_sha1 ( string $clear, string $salt = null, array $opts = [] ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$opts array ('iter' => iterations)
리턴 string Hashed password

hash_djangopbkdf2_sha256() 공개 메소드

Alias for djangopbkdf2 defaulting to sha256 as hash algorithm
public hash_djangopbkdf2_sha256 ( string $clear, string $salt = null, array $opts = [] ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$opts array ('iter' => iterations)
리턴 string Hashed password

hash_djangosha1() 공개 메소드

Uses salted SHA1 hashs. Salt is 5 bytes long. This is used by the Django Python framework
public hash_djangosha1 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_hmd5() 공개 메소드

Alias for hash_pmd5
public hash_hmd5 ( $clear, $salt = null, $magic = 'H', $compute = 8 )

hash_kmd5() 공개 메소드

Uses salted MD5 hashs. Salt is 2 bytes long, but stored at position 16, so you need to pass at least 18 bytes. You can pass the crypted hash as salt.
public hash_kmd5 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_lsmd5() 공개 메소드

Uses salted MD5 hashs. Salt is 8 bytes long. This is the format used by LDAP.
public hash_lsmd5 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_md5() 공개 메소드

Uses MD5 hashs.
public hash_md5 ( string $clear ) : string
$clear string The clear text to hash
리턴 string Hashed password

hash_mediawiki() 공개 메소드

Uses salted MD5, this is referred to as Method B in MediaWiki docs. Unsalted md5 method 'A' is not supported.
public hash_mediawiki ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_my411() 공개 메소드

Uses SHA1 hashs. This method is used by MySQL 4.11 and above
public hash_my411 ( string $clear ) : string
$clear string The clear text to hash
리턴 string Hashed password

hash_mysql() 공개 메소드

This method was used by old MySQL systems
public hash_mysql ( string $clear ) : string
$clear string The clear text to hash
리턴 string Hashed password

hash_pmd5() 공개 메소드

Uses salted MD5 hashs. Salt is 1+8 bytes long, 1st byte is the iteration count when given, for null salts $compute is used. The actual iteration count is the given count squared, maximum is 30 (-> 1073741824). If a higher one is given, the function throws an exception.
public hash_pmd5 ( string $clear, string $salt = null, string $magic = 'P', integer $compute = 8 ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
$magic string The hash identifier (P or H)
$compute integer The iteration count for new passwords
리턴 string Hashed password

hash_sha1() 공개 메소드

Uses SHA1 hashs.
public hash_sha1 ( string $clear ) : string
$clear string The clear text to hash
리턴 string Hashed password

hash_sha512() 공개 메소드

This is only supported on PHP 5.3.2 or higher and will throw an exception if the needed crypt support is not available
public hash_sha512 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_smd5() 공개 메소드

Uses salted MD5 hashs. Salt is 8 bytes long. The same mechanism is used by Apache's 'apr1' method. This will fallback to a implementation in pure PHP if MD5 support is not available in crypt()
public hash_smd5 ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hash_ssha() 공개 메소드

Uses salted SHA1 hashs. Salt is 4 bytes long.
public hash_ssha ( string $clear, string $salt = null ) : string
$clear string The clear text to hash
$salt string The salt to use, null for random
리턴 string Hashed password

hmac() 공개 정적인 메소드

This is not directly used as password hashing method, and thus isn't callable via the verify_hash() method. It should be used to create signatures and might be used in other password hashing methods.
또한 보기: hash_hmac()
저자: KC Cloyd
public static hmac ( string $algo, string $data, string $key, boolean $raw_output = false ) : string
$algo string Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..) See hash_algos() for a list of supported algorithms.
$data string Message to be hashed.
$key string Shared secret key used for generating the HMAC variant of the message digest.
$raw_output boolean When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits.
리턴 string

init_salt() 공개 메소드

If $salt is not null, the value is kept, but the lenght restriction is applied (unless, $cut is false).
public init_salt ( &$salt, integer $len = 32, boolean $cut = true )
$len integer The length of the salt
$cut boolean Apply length restriction to existing salt?

random() 보호된 메소드

Use DokuWiki's secure random generator if available
protected random ( integer $min, integer $max ) : integer
$min integer
$max integer
리턴 integer

verify_hash() 공개 메소드

The method and salt used for the crypted hash is determined automatically, then the clear text password is crypted using the same method. If both hashs match true is is returned else false
저자: Andreas Gohr ([email protected])
public verify_hash ( string $clear, string $hash ) : boolean
$clear string Clear-Text password
$hash string Hash to compare against
리턴 boolean