Support the ongoing development of Laravel.io →
Authentication Security Validation

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?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.