Page MenuHomeWickedGov Phorge

HashLibrary.php
No OneTemporary

Size
920 B
Referenced Files
None
Subscribers
None

HashLibrary.php

<?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

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)

Event Timeline