(PHP 5 >= 5.5.0, PHP 7)
password_needs_rehash — 锟斤拷锟缴拷锟街碉拷欠锟狡ワ拷锟街革拷锟斤拷锟窖★拷锟�
$hash
, int $algo
[, array $options
] ) : bool锟剿猴拷锟斤拷锟斤拷锟街革拷锟斤拷锟缴拷锟街碉拷欠锟绞碉拷锟斤拷锟斤拷峁╋拷锟斤拷惴拷锟窖★拷睢� 锟斤拷锟矫伙拷校锟斤拷锟揭拷锟斤拷锟斤拷锟斤拷锟缴拷锟街碉拷锟�
hash
一锟斤拷锟斤拷 password_hash() 锟斤拷锟斤拷锟斤拷散锟斤拷值锟斤拷
algo
一锟斤拷锟斤拷锟斤拷锟斤拷散锟斤拷锟斤拷锟斤拷时指示锟姐法锟斤拷锟斤拷锟斤拷锟姐法锟斤拷锟斤拷锟斤拷
options
一锟斤拷锟斤拷锟斤拷锟斤拷选锟斤拷墓锟斤拷锟斤拷锟斤拷椤D壳爸э拷锟斤拷锟斤拷锟窖★拷睿�salt锟斤拷锟斤拷散锟斤拷锟斤拷锟斤拷时锟接碉拷锟轿o拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟皆硷拷cost锟斤拷锟斤拷锟斤拷指锟斤拷锟姐法锟捷癸拷牟锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟街碉拷锟斤拷锟斤拷涌锟斤拷锟� crypt() 页锟斤拷锟揭碉拷锟斤拷
Example #1 password_needs_rehash()锟矫凤拷
<?php
$password = 'rasmuslerdorf';
$hash = '$2y$10$YCFsG6elYca568hBi2pZ0.3LDL5wjgxct1N8w/oLR/jfHsiQwCqTS';
// 锟斤拷硬锟斤拷锟斤拷锟杰得碉拷锟斤拷锟斤拷时锟斤拷cost 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟睫革拷
$options = array('cost' => 11);
// 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷证锟斤拷锟斤拷锟缴拷锟�
if (password_verify($password, $hash)) {
// 锟斤拷锟斤拷欠锟斤拷懈锟斤拷碌目锟斤拷锟缴拷锟斤拷惴�
// 锟斤拷锟斤拷 cost 锟斤拷锟斤拷锟戒化
if (password_needs_rehash($hash, PASSWORD_DEFAULT, $options)) {
// 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷虼唇锟斤拷锟缴拷校锟斤拷婊伙拷锟缴拷锟�
$newHash = password_hash($password, PASSWORD_DEFAULT, $options);
}
// 使锟矫伙拷锟斤拷录
}
?>
锟斤拷锟缴拷锟斤拷锟揭拷锟斤拷锟斤拷锟斤拷刹锟斤拷锟狡ワ拷锟街革拷锟斤拷锟� algo
锟斤拷 options
锟斤拷
锟津返伙拷 TRUE
锟斤拷锟斤拷锟津返伙拷 FALSE
锟斤拷