PasswordHelper

Filepath: phork/php/utilities/PasswordHelper.class.php

The PasswordHelper class is used to encrypt and validate passwords. It uses PHP's hash() function and adds an additional salt to the password before encrypting it.

Because the encryption is one way, the way to validate a password is to re-encrypt it using the same hashing algorithm and salt and see if it matches the already encrypted value.


Example

//example encrypted output: SHA-1:hyRK7x:af129785ebba5ad73fcc4fa678b482758be2285c
$strEncrypted = PasswordHelper::encryptPassword('secret');

//compare the encrypted password with the plain text password
$blnValid = PasswordHelper::validatePassword($strEncrypted, 'secret');