lithium\tests\cases\security\PasswordTest::testSaltMD5 PHP Method

testSaltMD5() public method

Tests salting passwords with the MD5 algorithm.
public testSaltMD5 ( )
    public function testSaltMD5()
    {
        $this->skipIf(!CRYPT_MD5, 'MD5 is not supported.');
        $saltPattern = "{^\\\$1\\\$[0-9A-Za-z./]{8}\$}";
        $hashPattern = "{^\\\$1\\\$[0-9A-Za-z./]{8}\\\$[0-9A-Za-z./]{22}\$}";
        $salt = Password::salt('md5', null);
        $this->assertPattern($saltPattern, $salt);
        $this->assertNotEqual($salt, Password::salt('md5', null));
        $hash = Password::hash($this->_password, $salt);
        $hash2 = Password::hash($this->_password, Password::salt('md5', null));
        $this->assertPattern($hashPattern, $hash);
        $this->assertNotEqual($hash, $hash2);
    }