octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 02:13:17 +08:00
Fallback at Security::generateRandomKey() removed
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 1 changed files with 2 additions and 6 deletions
@@ -180,7 +180,7 @@ class Security extends Component
|
|||||||
$end = StringHelper::byteSubstr($data, -1, null);
|
$end = StringHelper::byteSubstr($data, -1, null);
|
||||||
$last = ord($end);
|
$last = ord($end);
|
||||||
$n = StringHelper::byteLength($data) - $last;
|
$n = StringHelper::byteLength($data) - $last;
|
||||||
if (StringHelper::byteSubstr($data, $n, null) == str_repeat($end, $last)) {
|
if (StringHelper::byteSubstr($data, $n, null) === str_repeat($end, $last)) {
|
||||||
return StringHelper::byteSubstr($data, 0, $n);
|
return StringHelper::byteSubstr($data, 0, $n);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,11 +322,7 @@ class Security extends Component
|
|||||||
*/
|
*/
|
||||||
public function generateRandomKey($length = 32)
|
public function generateRandomKey($length = 32)
|
||||||
{
|
{
|
||||||
if (function_exists('mcrypt_create_iv')) {
|
return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
|
||||||
return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
|
|
||||||
}
|
|
||||||
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.';
|
|
||||||
return substr(str_shuffle(str_repeat($chars, 5)), 0, $length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user