A collection of functions which can be used for security purposes.
Install through composer and require the autoloader.
composer require crecket/secure-functions
Download the files and require them in your project.
require '/secure-functions/src/SecureFuncs.php';
Install the php module if you want to use scrypt hashing
All functions are static public functions right now so you can simply call the functions like this:
SecureFuncs\SecureFuncs::password_hash('input');
Compare strings while preventing timed attacks
Verify a form token for the given id. The $limit is optional andm ust be given in seconds, if the limit is 300 and the token is used after 300 seconds it will be considered invalid.
Hash the given password. This function allows for longer passwords and isn't affected by the null-byte issue.
Verify the given password hash
Returns a random hexadecimal number for the given length
Returns the a secure random integer within the given range.
Returns a random string for the given length
Compare a password and hash using DomBlack/php-scrypt
Hash a password using DomBlack's php scrypt library
Set a unique token in the session and returns it, can be used to verify post/get requests
Returns the length of the given string using mb_strlen when available
Returns random bytes for the given length