Pop\Crypt\Md5::create PHP Метод

create() публичный Метод

Method to create the hashed value
public create ( string $string ) : string
$string string
Результат string
    public function create($string)
    {
        $hash = null;
        $this->salt = null === $this->salt ? substr(str_replace('+', '.', base64_encode(String::random(32))), 0, 9) : substr(str_replace('+', '.', base64_encode($this->salt)), 0, 9);
        $hash = crypt($string, '$1$' . $this->salt);
        return $hash;
    }

Usage Example

Пример #1
0
 public function testMd5()
 {
     $crypt = new Crypt\Md5();
     $crypt->setSalt('Test Salt');
     $this->assertEquals('Test Salt', $crypt->getSalt());
     $hash = $crypt->create('12password34');
     $this->assertTrue($crypt->verify('12password34', $hash));
 }
All Usage Examples Of Pop\Crypt\Md5::create