Skip to content

Password Functions


password\generate( )

The password\generate() function returns a system generated password.

password\generate()
password\generate(): STRING

Example:

password\generate() Example
$password = password\generate();
output\print($password);


password\hash( )

The password\hash() function returns a hashed version of the INPUT value. The same input will always generate the same hashed value.

A hash() function is commonly used for storing passwords in a secure and encrypted form. Instead of storing the actual password, which is considered to be a security risk, a hash function is used to convert the password into a fixed-length string of characters that is unique to the password. The hash function generates this fixed-length string, known as a hash value, by applying a mathematical algorithm to the password.

Hash functions are designed to be one-way functions, which means they can convert data into a fixed-size string of characters, but the process is not reversible. This property is what makes hashing a secure method for storing passwords, as it prevents anyone from retrieving the original password from the hash.

When a user enters their password to log in, the hash function is applied again to the entered password, and the resulting hash value is compared to the hash value stored in the database. If the two hash values match, it means that the entered password is correct, and the user is granted access. However, if the two hash values do not match, it means that the entered password is incorrect, and the user is denied access.

Hashing passwords is considered to be a best practice in terms of security because it ensures that even if a hacker gains access to the database, they will not be able to retrieve the actual passwords. Instead, they will only be able to see the hash values, which are typically very difficult to reverse engineer. This means that even if a hacker knows the hash value, they cannot use it to log in to the system or access the user's account.

password\hash()
password\hash(INPUT): STRING

Example:

password\hash() Example
$password = password\generate(); // Example result: '8jD4nEHI0S'
$hash = password\hash($password); // Returns 'AwDaMjhIxapOxYkDL.RcXVOsSLeor4ylM8qszx.CI5mAqeEkaV84WwxaUBjpbbrCgzMeu7DR0Y6M0qOyrxBQ11'


See Also