67 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Components;
 | 
						|
 | 
						|
use Illuminate\Contracts\Hashing\Hasher;
 | 
						|
use Illuminate\Hashing\HashManager;
 | 
						|
 | 
						|
/**
 | 
						|
 * Description of Md5Hasher
 | 
						|
 *
 | 
						|
 * @author Andrey Pokidov <pokidov@e-traffic.ru>
 | 
						|
 */
 | 
						|
class MD5Hasher extends HashManager
 | 
						|
{
 | 
						|
    public function __construct()
 | 
						|
    {
 | 
						|
        parent::__construct(app());
 | 
						|
    }
 | 
						|
    /**
 | 
						|
     * Get information about the given hashed value.
 | 
						|
     *
 | 
						|
     * @param  string  $hashedValue
 | 
						|
     * @return array
 | 
						|
     */
 | 
						|
    public function info($hashedValue)
 | 
						|
    {
 | 
						|
        return [];
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Hash the given value.
 | 
						|
     *
 | 
						|
     * @param  string  $value
 | 
						|
     * @param  array  $options
 | 
						|
     * @return string
 | 
						|
     */
 | 
						|
    public function make($value, array $options = [])
 | 
						|
    {
 | 
						|
        return md5($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 = [])
 | 
						|
    {
 | 
						|
        return strtolower(md5($value)) == strtolower($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 = [])
 | 
						|
    {
 | 
						|
        return false;
 | 
						|
    }
 | 
						|
}
 |