Page Menu
Home
WMGMC Issues
搜索
Configure Global Search
登录
Files
F15898
HashRNGProvider.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
订阅
标记用于日后
授予令牌
Size
952 B
Referenced Files
None
订阅者
None
HashRNGProvider.php
View Options
<?php
namespace
RobThree\Auth\Providers\Rng
;
class
HashRNGProvider
implements
IRNGProvider
{
/** @var string */
private
$algorithm
;
/**
* @param string $algorithm
*/
public
function
__construct
(
$algorithm
=
'sha256'
)
{
$algos
=
array_values
(
hash_algos
());
if
(!
in_array
(
$algorithm
,
$algos
,
true
))
{
throw
new
RNGException
(
'Unsupported algorithm specified'
);
}
$this
->
algorithm
=
$algorithm
;
}
/**
* {@inheritdoc}
*/
public
function
getRandomBytes
(
$bytecount
)
{
$result
=
''
;
$hash
=
mt_rand
();
for
(
$i
=
0
;
$i
<
$bytecount
;
$i
++)
{
$hash
=
hash
(
$this
->
algorithm
,
$hash
.
mt_rand
(),
true
);
$result
.=
$hash
[
mt_rand
(
0
,
strlen
(
$hash
)
-
1
)];
}
return
$result
;
}
/**
* {@inheritdoc}
*/
public
function
isCryptographicallySecure
()
{
return
false
;
}
}
File Metadata
详情
附加的
Mime Type
text/x-php
Expires
9月 9 Tue, 5:47 AM (10 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5384
默认替代文本
HashRNGProvider.php (952 B)
Attached To
Mode
rMAILCOW mailcow-tracking
附加的
Detach File
Event Timeline
Log In to Comment