20 lines
480 B
PHP
20 lines
480 B
PHP
<?php
|
|
namespace Cadoles\CoreBundle\Service;
|
|
|
|
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
|
|
|
class passwordEncoder implements PasswordEncoderInterface
|
|
{
|
|
|
|
public function encodePassword($raw, $salt)
|
|
{
|
|
$hash = "{SSHA}" . base64_encode(pack("H*", sha1($raw . $salt)) . $salt);
|
|
return $hash;
|
|
}
|
|
|
|
public function isPasswordValid($encoded, $raw, $salt)
|
|
{
|
|
return $encoded === $this->encodePassword($raw, $salt);
|
|
}
|
|
|
|
} |