本文整理汇总了PHP中password_get_info函数的典型用法代码示例。如果您正苦于以下问题:PHP password_get_info函数的具体用法?PHP password_get_info怎么用?PHP password_get_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了password_get_info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getHashInfo
public function getHashInfo($hash)
{
$passwordGetInfoResult = password_get_info($hash);
$identifier = $passwordGetInfoResult[HashInfo::ALGORITHM_ID_KEY];
$name = $passwordGetInfoResult[HashInfo::ALGORITHM_NAME_KEY];
$options = $passwordGetInfoResult[HashInfo::OPTIONS_KEY];
return new HashInfo($identifier, $name, $options);
}
开发者ID:jonasrudolph,项目名称:php-component-password,代码行数:8,代码来源:PasswordService.php
示例2: update
public function update($params)
{
if (isset($params['password'])) {
if (!password_get_info($params['password'])['algo']) {
$params['password'] = password_hash($params['password'], PASSWORD_DEFAULT);
}
}
return parent::update($params);
}
开发者ID:ngchie,项目名称:system,代码行数:9,代码来源:Users.php
示例3: password_hashing
public function password_hashing()
{
echo '<a href="http://www.codeigniter.com/user_guide/general/compatibility_functions.html">read</a>';
$hash = 'password_hash';
echo password_hash($hash, PASSWORD_DEFAULT);
echo password_get_info($hash);
echo password_needs_rehash($hash, PASSWORD_DEFAULT);
echo password_verify('password_hash', $hash);
}
开发者ID:psosulski,项目名称:ci,代码行数:9,代码来源:Examples.php
示例4: __construct
/**
* @param string $password
* @param boolean $automateHash
*/
public function __construct($password, $automateHash = false)
{
$this->password = (string) $password;
$info = password_get_info($this->password);
$this->isHashed = 'unknown' !== $info['algoName'];
if ($automateHash) {
$this->hash();
}
}
开发者ID:thesoftwarefactoryuk,项目名称:SenNetwork,代码行数:13,代码来源:Password.php
示例5: getInfo
/**
* @param string $hash
* @return array
*/
public function getInfo($hash)
{
$clear = Helpers::getHash($hash);
$signatureLength = $this->getSignatureLength();
$ivLength = $this->getIvLength();
if (!$this->verifySignature(Helpers::substr($clear, 0, $signatureLength), Helpers::substr($clear, $signatureLength))) {
throw new \Ark8\Passwords\Exceptions\SignatureException('Signature does not match.');
}
return password_get_info($this->decrypt(Helpers::substr($clear, $signatureLength, $ivLength), Helpers::substr($clear, $signatureLength + $ivLength)));
}
开发者ID:ark8,项目名称:passwords,代码行数:14,代码来源:Passwords.php
示例6: __construct
/**
* Constructor
*
* @param string $hash
*/
public function __construct($hash)
{
if (!is_string($hash)) {
throw new DataType('hash', 'string', $hash);
}
$hashInfos = password_get_info($hash);
if ($hashInfos['algo'] === 0) {
throw new DataFormat('hash', 'a valid password hash', $hash);
}
$this->hash = $hash;
}
开发者ID:broeser,项目名称:wellid,代码行数:16,代码来源:Password.php
示例7: saving
public function saving($model)
{
foreach ($this->options['fields'] as $field) {
$password = (string) $model[$field];
$info = password_get_info($password);
if ($info['algo'] === 0) {
// needs to be rehashed
$model[$field] = password_hash($password, $this->options['algo'], $this->options['options']);
}
}
}
开发者ID:xinix-technology,项目名称:norm,代码行数:11,代码来源:Hashable.php
示例8: setHash
public function setHash(string $hash) : PasswordInterface
{
if (empty($hash)) {
throw new PasswordException('hash is empty');
}
if (password_get_info($hash)['algo'] === 0) {
throw new PasswordException('The hash is not understandable by the underlying library');
}
$this->hashed = $hash;
$this->isHashed = true;
return $this;
}
开发者ID:arabcoders,项目名称:password,代码行数:12,代码来源:Password.php
示例9: __construct
public function __construct($hashedPassword)
{
if (!is_string($hashedPassword) || empty($hashedPassword)) {
throw new HashedPasswordException('The hashedPassword must be a non-empty string.');
}
$info = password_get_info($hashedPassword);
if (empty($info) || !isset($info['algo']) || empty($info['algo'])) {
throw new HashedPasswordException('The given hashedPassword (' . $hashedPassword . ') is invalid.');
}
$this->hashedPassword = $hashedPassword;
$this->algo = $info['algo'];
}
开发者ID:steve-rodrigue,项目名称:authenticated-apis,代码行数:12,代码来源:ConcreteHashedPassword.php
示例10: canUpgradeInternalHash
protected function canUpgradeInternalHash(PhutilOpaqueEnvelope $hash)
{
$info = password_get_info($hash->openEnvelope());
// NOTE: If the costs don't match -- even if the new cost is lower than
// the old cost -- count this as an upgrade. This allows costs to be
// adjusted down and hashing to be migrated toward the new cost if costs
// are ever configured too high for some reason.
$cost = idx($info['options'], 'cost');
if ($cost != $this->getBcryptCost()) {
return true;
}
return false;
}
开发者ID:pugong,项目名称:phabricator,代码行数:13,代码来源:PhabricatorBcryptPasswordHasher.php
示例11: test_password_get_info
/**
* password_get_info() test
*
* Borrowed from PHP's own tests
*
* @depends test_bootstrap
*/
public function test_password_get_info()
{
$expected = array('algo' => 1, 'algoName' => 'bcrypt', 'options' => array('cost' => 10));
// default
$this->assertEquals($expected, password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
$expected['options']['cost'] = 11;
// cost
$this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y'));
$expected = array('algo' => 0, 'algoName' => 'unknown', 'options' => array());
// invalid length
$this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100'));
// non-bcrypt
$this->assertEquals($expected, password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0'));
}
开发者ID:saiful1105020,项目名称:Under-Construction-Bracathon-Project-,代码行数:21,代码来源:password_test.php
示例12: getType
public static function getType($hash)
{
$info = password_get_info($hash);
if ($info['algo'] > 0) {
return $info['algoName'];
}
if (substr($hash, 0, 3) == '$P$') {
return 'phpass';
}
if (preg_match('/^[A-Z0-9]{32}\\:[A-Z0-9]{2}$/i', $hash) === 1) {
return 'salt';
}
trigger_error('OSC\\OM\\Hash::getType() hash type not found for "' . substr($hash, 0, 5) . '"');
return '';
}
开发者ID:haraldpdl,项目名称:oscommerce2,代码行数:15,代码来源:Hash.php
示例13: password_needs_rehash
function password_needs_rehash($hash, $algorithm, $options = array())
{
$info = password_get_info($hash);
if ($info['algo'] != $algorithm) {
return true;
}
switch ($algorithm) {
case PASSWORD_BCRYPT:
$cost = isset($options['cost']) ? $options['cost'] : 10;
if ($cost != $info['options']['cost']) {
return true;
}
break;
}
return false;
}
开发者ID:juancamiloestela,项目名称:RocketPHP,代码行数:16,代码来源:Helpers.php
示例14: verifyPassword
public function verifyPassword($password)
{
if (!defined('PASSWORD_DEFAULT')) {
require_once LIB_PATH . 'password_compat/password.php';
}
$this->loggedIn = password_verify($password, $this->PasswordHash) === true;
if ($this->loggedIn) {
// Verify password hash algorithm and strength requirements. -- cwells
$passwordInfo = password_get_info($this->PasswordHash);
if (password_needs_rehash($this->PasswordHash, PASSWORD_DEFAULT, $passwordInfo['options']) === true || $passwordInfo['options']['cost'] !== self::HASH_COST) {
// No need to verify success here since we'll try again on the next login. -- cwells
$this->setPassword($password);
}
}
return $this->loggedIn;
}
开发者ID:chriswells0,项目名称:cwa-lib,代码行数:16,代码来源:User.php
示例15: passwordHash
/**
* Get the password hash if it is plaintext.
* If hashed password is passed, so just returns it.
*
* @param RecoveryAccess|string $password Password to hash.
*
* @return string
*/
public static function passwordHash($password)
{
if ($password instanceof RecoveryAccess) {
$password = $password->password;
}
// Check password status.
// It should detect if is a hashed password.
$passwordStatus = password_get_info($password);
if ($passwordStatus['algo'] === 0) {
$hashOptions = [];
// Overwrite the default cost.
if (defined('VANILLA_RECOVERY_HASH_COST')) {
$hashOptions['cost'] = VANILLA_RECOVERY_HASH_COST;
}
return (string) password_hash($password, PASSWORD_BCRYPT, $hashOptions);
}
return $password;
}
开发者ID:VanillaPackage,项目名称:vanilla-recovery,代码行数:26,代码来源:Helper.php
示例16: checkPasswordSecurity
/**
* checks if the hashed password still meets our security requirements. false if rehash is needed
* @param string $hash current hash
* @return bool
*/
public static function checkPasswordSecurity($hash)
{
/*
* PHP offers a password_needs_rehash() function, but it only checks if the values are the same.
* e.g. having a different hashing cost for one password would result in rehashing and losing security
* We check both relevant values ourselves and make sure we don't rehash unnecessarily
*/
// check if cost is too little
$info = password_get_info($hash);
if ($info['options']['cost'] < self::HASHING_COST) {
return true;
}
// check if algo has changed
if ($info['algo'] != self::HASHING_ALGO) {
return true;
}
return false;
}
开发者ID:aelix,项目名称:framework,代码行数:23,代码来源:USecurity.php
示例17: fromDataToCredentials
public function fromDataToCredentials(array $data)
{
if (!isset($data['username'])) {
throw new CredentialsException('The username keyname is mandatory in order to convert the data to a Credentials object.');
}
if (!isset($data['password'])) {
throw new CredentialsException('The password keyname is mandatory in order to convert the data to a Credentials object.');
}
$password = null;
$hashedPassword = null;
$info = password_get_info($data['password']);
if (!empty($info) && isset($info['algo']) && !empty($info['algo'])) {
$hashedPassword = new ConcreteHashedPassword($data['password']);
}
if (empty($hashedPassword)) {
$password = $data['password'];
$hashedPassword = new ConcreteHashedPassword(password_hash($password, \PASSWORD_DEFAULT));
}
return new ConcreteCredentials($data['username'], $hashedPassword, $password);
}
开发者ID:steve-rodrigue,项目名称:authenticated-apis,代码行数:20,代码来源:ConcreteCredentialsAdapter.php
示例18: checkPassword
public function checkPassword($password)
{
$passwordInfo = password_get_info($this->password);
// Check for legacy unsalted SHA1
if (strlen($this->password) == 40 && $passwordInfo['algoName'] == "unknown") {
if (hash("SHA1", $password) == $this->password) {
$this->setPassword($password);
TigerApp::log("Password for {$this->username} rehashed (Legacy).");
return true;
}
}
if (password_verify($password, $this->password)) {
// success. But check for needing to be rehashed.
if (password_needs_rehash($this->password, PASSWORD_DEFAULT)) {
$this->setPassword($password);
$this->save();
TigerApp::log("Password for {$this->username} rehashed ({$passwordInfo['algoName']}).");
}
return true;
} else {
return false;
}
}
开发者ID:Thruio,项目名称:TigerKit,代码行数:23,代码来源:User.php
示例19: var_dump
<?php
var_dump(PASSWORD_DEFAULT == PASSWORD_BCRYPT);
// true
$password = 'hello';
// will be truncaged to 72 chars
$hashed = password_hash($password, PASSWORD_DEFAULT);
echo $hashed . PHP_EOL;
var_dump(password_get_info($hashed));
var_dump(password_verify($password, $hashed));
echo PHP_EOL;
开发者ID:pixlr,项目名称:zce-3,代码行数:11,代码来源:passwords.php
示例20: getInfos
/**
* Get information about the password hash. Returns an array of the information
* that was used to generate the password hash.
*
* array(
* 'algo' => 1,
* 'algoName' => 'bcrypt',
* 'options' => array(
* 'cost' => 10,
* ),
* )
*
* @param string $hash The password hash to extract info from
*
* @return array The array of information about the hash.
*/
public static function getInfos($hash)
{
return password_get_info($hash);
}
开发者ID:sisnox,项目名称:framework,代码行数:20,代码来源:Password.php
注:本文中的password_get_info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论