SYNOPSIS
DESCRIPTION
Calculate a password hash out of the plain text password which is salted with the value salt. While the hash can be easily calculated from a password, it is reasonably impossible to do the reverse.
This function is used for checking a password.
First the user has to select a password. The software will generate a random salt value and run both the newly entered password and the salt through cipher.crypt(). The resulting hash value is stored in the user database:
When the password must be verified, the application software needs to retrieve the stored hash value from its database check it against the password. This example will return true if the password is correct.
NOTES
The function uses MD5 to calculate the hash. The algorithm is compatible to most unix implementations. It uses the implementation from OpenBSD.
The structure of a hash is like this:
The tag $1 marks the hash as MD5 encoded. Following after another $ character is the salt, and finally the hash data.