Fire\Hash\Hash provides an easy interface for encrypting/decrypting and hashing strings.
Note: sFire\Hash\Hash uses the open_ssl library.
To encrypt a string you may use the encrypt method. This methods accepts two parameters.
Hash :: encrypt(string $message, string $key);
$encrypted = Hash :: encrypt('Hello world!', 'H6DqnA9N52mDpa63c');
To decrypt a String what is encrypted with the encrypt method, you can use the decrypt method. This methods accepts two parameters.
Hash :: decrypt(string $message, string $key);
To hash a string you can use the hash method. This methods accepts one parameter.
Hash :: hash(string $message);
Example:
$hash = Hash :: hash('Hello world!');
Verifies that data matches a hash. To validate a hashed String you can use the validateHash method. This methods accepts two parameters. The first parameter is a String that will be matched against the second String and already hashed parameter.
Hash :: validateHash(string $data, string $hash);
use sFire\Hash\Hash;
$hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';
$validate = Hash :: validateHash('rasmuslerdorf', $hash);
if(true === $validate) {
//Hash is valid
}