Predefined Constants (original) (raw)

The constants below are always available as part of the PHP core.

PASSWORD_BCRYPT (string)

PASSWORD_BCRYPT is used to create new password hashes using the CRYPT_BLOWFISH algorithm.

This will always result in a hash using the "$2y$" crypt format, which is always 60 characters wide.

Supported Options:

PASSWORD_ARGON2I (string)

PASSWORD_ARGON2I is used to create new password hashes using the Argon2i algorithm.

Supported Options:

Available as of PHP 7.2.0.

PASSWORD_ARGON2ID (string)

PASSWORD_ARGON2ID is used to create new password hashes using the Argon2id algorithm. It supports the same options asPASSWORD_ARGON2I.

Available as of PHP 7.3.0.

PASSWORD_ARGON2_DEFAULT_MEMORY_COST (integer)

Default amount of memory in bytes that Argon2lib will use while trying to compute a hash.

Available as of PHP 7.2.0.

PASSWORD_ARGON2_DEFAULT_TIME_COST (integer)

Default amount of time that Argon2lib will spend trying to compute a hash.

Available as of PHP 7.2.0.

PASSWORD_ARGON2_DEFAULT_THREADS (integer)

Default number of threads that Argon2lib will use.

Available as of PHP 7.2.0.

PASSWORD_DEFAULT (mixed)

The default algorithm to use for hashing if no algorithm is provided. This may change in newer PHP releases when newer, stronger hashing algorithms are supported.

It is worth noting that over time this constant can (and likely will) change. Therefore you should be aware that the length of the resulting hash can change. Therefore, if you use PASSWORD_DEFAULT you should store the resulting hash in a way that can store more than 60 characters (255 is the recommended width).

Values for this constant:

Changelog
Version Description
7.4.0 The values of the password algo IDs (PASSWORD_BCRYPT, PASSWORD_ARGON2I,PASSWORD_ARGON2ID and PASSWORD_DEFAULT) are now strings. Previously, they have been integers.