Created
September 15, 2013 14:23
-
-
Save richsage/6571186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\DemoBundle\Security\Encoder; | |
use Symfony\Component\Security\Core\Encoder\BasePasswordEncoder; | |
class MySQLPasswordEncoder extends BasePasswordEncoder | |
{ | |
/** | |
* {@inheritdoc} | |
*/ | |
public function encodePassword($raw, $salt) | |
{ | |
return $this->doEncode($raw); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function isPasswordValid($encoded, $raw, $salt) | |
{ | |
$pass2 = $this->doEncode($raw); | |
return $this->comparePasswords($encoded, $pass2); | |
} | |
/** | |
* Do the actual encoding | |
* @param $input | |
* @return string | |
*/ | |
protected function doEncode($input) | |
{ | |
$sha1_stage1 = sha1($input, true); | |
$output = sha1($sha1_stage1, false); | |
return "*" . strtoupper($output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment