-
Notifications
You must be signed in to change notification settings - Fork 194
Helper Hash
Name | Path |
---|---|
Hash Helper | /application/helpers/hash_helper.php |
These encryption methods will do the base64 encoding and decoding for you. It is wise to use the base64 version of the encrypted string for database storage as there are no conflicting DB characters present and it can be decoded back to the raw hash easily.
$this->load->helper('hash_helper');
Creates and returns a random 50 character string to be used for CSRF authentication.
$csrf_token = generateCSRF();
Create a secure hash of a string. It cycles thru different encryption types from best to worst and returns a one-way encrypted string.
Variable | Type | Default | Required | Description |
---|---|---|---|---|
$str | string | N/A | Yes | The string to create a hash for |
$password = generateHash('Your String');
Creates a 12 character password that has at least one capital letter, one lowercase letter and one numeric.
$password = generatePassword();
Creates a random token at the length specified.
Variable | Type | Default | Required | Description |
---|---|---|---|---|
$len | integer | 20 | Yes | The length of the token |
$token = generateToken();
Evaluates each letter of the string. It looks for at least one capital letter, one lower case and one numeric to return true.
Variable | Type | Default | Required | Description |
---|---|---|---|---|
$str | String | N/A | Yes | The string to evaluate. |
if (isStong($str) === true) {
// Good for you
}
Compares a base64 encoded hash against a plain text string to see if they match. This function will base64 decode the encoded string for you and use it as a salt for comparisons.
Variable | Type | Default | Required | Description |
---|---|---|---|---|
$str | string | N/A | Yes | The string to evaluate against |
$hash | string | N/A | Yes | The base64 encoded, crypt string to use for the sale |
if (verifyHash('Your String', $encrypted_password)) {
//Hey it works!
}