- laravel 9.x or later
- php 8.x
-
Input your command line in below command.
composer require qnibus/laravel-multi-hash
-
Open
/config/hashing.php
in your laravel application and modify.'driver' => 'jasypt',// 'md5', 'sha256', 'sha512' or 'jasypt'
-
Your code anywhere...
# make hash Hash::make('some string'); // result: NDM1M2M0ZmQ3MWYzNmJiZIXQlXLOzKcLkUKAZ6p6NPBBDA0zGwVCDkFuLmvbeozd # check hash Hash::check('some string', 'NDM1M2M0ZmQ3MWYzNmJiZIXQlXLOzKcLkUKAZ6p6NPBBDA0zGwVCDkFuLmvbeozd'); // result: true
-
Publish package config to config directory in laravel.
php artisan vendor:publish --tag=multi-hashing-config
-
Modify option in
/config/multi-hashing.php
# Usage for jasypt
Hash::driver('jasypt')->make('some string');
Hash::driver('jasypt')->check('some string', $hashedString);
# Usage for sha256
Hash::driver('sha256')->make('some string');
Hash::driver('sha256')->check('some string', $hashedString);
# Usage for sha512
Hash::driver('sha512')->make('some string');
Hash::driver('sha512')->check('some string', $hashedString);
# Usage for md5
Hash::driver('md5')->make('some string');
Hash::driver('md5')->check('some string', $hashedString);