本文整理匯總了PHP中Password::Password方法的典型用法代碼示例。如果您正苦於以下問題:PHP Password::Password方法的具體用法?PHP Password::Password怎麽用?PHP Password::Password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Password
的用法示例。
在下文中一共展示了Password::Password方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Validate
/**
* Validates if a hashed password is the correct hashed password for a given raw password, username and salt
* @param string $Username
* @param string $RawPassword the textual password (entered by user at login)
* @param string $HashedPassword the hashed password (retrived from database)
* @param string $Salt the dynamic salt (from database)
* @param integer $Protocol optional for backward compatibility
* @return boolean
*/
static function Validate($Username, $RawPassword, $HashedPassword, $Salt, $Protocol = null)
{
$temp = new Password($Username, $RawPassword, $Protocol);
$temp->Make($Username, $RawPassword, $Salt, $Protocol);
return $temp->Password() == $HashedPassword;
}
示例2: CreateUser
/**
Creates a new user in the system
@param Username of the new user
@param Password of the new user
@return integer UserID on success
null on User Already Exists
*/
function CreateUser($Username, $Password)
{
$Result = $this->UserExists($Username);
if ($Result) {
return null;
}
$HashedPass = new Password($Username, $Password);
$Result = jf::SQL("INSERT INTO {$this->TablePrefix()}users (Username,Password,Salt,Protocol)\n\t\t\tVALUES (?,?,?,?)", $Username, $HashedPass->Password(), $HashedPass->Salt(), $HashedPass->Protocol());
return $Result;
}