im doing it for learn about make changes in the hash/encriptions methods creating my own because sometimes u can say "just use bcrypt" if the client ask u for an especial hash or crypt u know
/**
Created a 'libraries' Folder => App/libraries that contains:
CustomHasher.php
CustomHashServiceProvider
CustomHasher.php looks like: **/
<?php namespace Libraries; class CustomHasher implements Illuminat\Contracts\Hashing\Hasher { /** * Hash the given value. * * @param string $value * @return array $options * @return string */ public function make($value, array $options = array()) { return hash('customHash', $value); } /** * Check the given plain value against a hash. * * @param string $value * @param string $hashedValue * @param array $options * @return bool */ public function check($value, $hashedValue, array $options = array()) { return $this->make($value) === $hashedValue; } /** * Check if the given hash has been using the given options. * @param string $hashedValue * @param array $options * @return bool */ public function needsRehash($hashedValue, array $options = array()) { return false; } }/**
CustomHashServiceProvider.php looks like: **/
<?php namespace Libraries; use Libraries\CustomHasher; use Illuminate\Hashing\HashServiceProvider; class CustomHashServiceProvider extends Illuminate\Support\ServiceProvider { /** * Register the service provider. * * @return void */ public function register() { $this->app['hash'] = $this->app->share(function () { return new CustomHasher(); }); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return array('hash'); } }/**
my app/helpers.php **/
<?php function customHash($value) { $value = strtoupper( sha1( sha1($value, true) ) ); $value = '*' . $value; return $value; }/**
in composer.json **/
"autoload": { "classmap": [ // ...
"app/libraries"
]
},
/**
the in App\config\app.php Providers: **/
//'Illuminate\Hashing\HashServiceProvider',
'CustomHashServiceProvider',
/**
later in cmd **/
composer dump-autoload
what is the next to make it work?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community