Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll have to rewrite the <code>Hash</code> module. Thanks to Laravel's ideas of following IoC and Dependency Injection concepts, it'll be relatively easy.</p> <p>First, create a <code>app/libraries</code> folder and add it to composer's <code>autoload.classmap</code>:</p> <pre><code>"autoload": { "classmap": [ // ... "app/libraries" ] }, </code></pre> <p>Now, it's time we create our class. Create a <code>SHAHasher</code> class, implementing <code>Illuminate\Hashing\HasherInterface</code>. We'll need to implement its 3 methods: <code>make</code>, <code>check</code> and <code>needsRehash</code>.</p> <p><strong>Note:</strong> On Laravel 5, implement <code>Illuminate/Contracts/Hashing/Hasher</code> instead of <code>Illuminate\Hashing\HasherInterface</code>.</p> <p><strong>app/libraries/SHAHasher.php</strong></p> <pre><code>class SHAHasher implements Illuminate\Hashing\HasherInterface { /** * Hash the given value. * * @param string $value * @return array $options * @return string */ public function make($value, array $options = array()) { return hash('sha1', $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-&gt;make($value) === $hashedValue; } /** * Check if the given hash has been hashed using the given options. * * @param string $hashedValue * @param array $options * @return bool */ public function needsRehash($hashedValue, array $options = array()) { return false; } } </code></pre> <p>Now that we have our class done, we want it to be used by default, by Laravel. To do so, we'll create <code>SHAHashServiceProvider</code>, extending <code>Illuminate\Support\ServiceProvider</code>, and register it as the <code>hash</code> component:</p> <p><strong>app/libraries/SHAHashServiceProvider.php</strong></p> <pre><code>class SHAHashServiceProvider extends Illuminate\Support\ServiceProvider { /** * Register the service provider. * * @return void */ public function register() { $this-&gt;app['hash'] = $this-&gt;app-&gt;share(function () { return new SHAHasher(); }); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return array('hash'); } } </code></pre> <p>Cool, now all we have to do is make sure our app loads the correct service provider. On <code>app/config/app.php</code>, under <code>providers</code>, remove the following line:</p> <pre><code>'Illuminate\Hashing\HashServiceProvider', </code></pre> <p>Then, add this one:</p> <pre><code>'SHAHashServiceProvider', </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload