Home >Backend Development >PHP Tutorial >How to Use SHA1 Encryption Instead of BCrypt in Laravel 4?
Using SHA1 Encryption with Laravel 4
To implement SHA1 encryption instead of BCrypt in Laravel 4, you must rewrite the Hash module. Laravel's dependency injection principles make this relatively straightforward.
Step 1: Create the SHAHasher Class
Create a SHAHasher class in app/libraries that implements the IlluminateHashingHasherInterface (or IlluminateContractsHashingHasher in Laravel 5). Implement the three required methods:
<code class="php">class SHAHasher implements Illuminate\Hashing\HasherInterface { // Hash a given value public function make($value, array $options = array()) {} // Verify a given plain value against a hash public function check($value, $hashedValue, array $options = array()) {} // Check if a hash needs to be rehashed public function needsRehash($hashedValue, array $options = array()) {} }</code>
Step 2: Register the SHAHasher Service Provider
Create a SHAHashServiceProvider in app/libraries that extends IlluminateSupportServiceProvider and registers it as the hash component:
<code class="php">class SHAHashServiceProvider extends Illuminate\Support\ServiceProvider { // Register the service provider public function register() {} // Get the services provided by the provider public function provides() {} }</code>
Step 3: Modify the App Configuration
Additional Notes
The above is the detailed content of How to Use SHA1 Encryption Instead of BCrypt in Laravel 4?. For more information, please follow other related articles on the PHP Chinese website!