Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6024796
HashLibrary.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
920 B
Referenced Files
None
Subscribers
None
HashLibrary.php
View Options
<?php
namespace
MediaWiki\Extension\Scribunto\Engines\LuaCommon
;
class
HashLibrary
extends
LibraryBase
{
public
function
register
()
{
$lib
=
[
'listAlgorithms'
=>
[
$this
,
'listAlgorithms'
],
'hashValue'
=>
[
$this
,
'hashValue'
],
];
return
$this
->
getEngine
()->
registerInterface
(
'mw.hash.lua'
,
$lib
);
}
/**
* Returns a list of known/ supported hash algorithms
*
* @internal
* @return string[][]
*/
public
function
listAlgorithms
()
{
$algos
=
hash_algos
();
$algos
=
array_combine
(
range
(
1
,
count
(
$algos
)
),
$algos
);
return
[
$algos
];
}
/**
* Hash a given value.
*
* @internal
* @param string $algo
* @param string $value
* @return string[]
*/
public
function
hashValue
(
$algo
,
$value
)
{
if
(
!
in_array
(
$algo
,
hash_algos
()
)
)
{
throw
new
LuaError
(
"Unknown hashing algorithm: $algo"
);
}
$hash
=
hash
(
$algo
,
$value
);
return
[
$hash
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 16:10 (6 w, 22 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
14/d2/085192481fb0da9427ef9cac2378
Default Alt Text
HashLibrary.php (920 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment