mediawiki-extensions-Scribunto/engines/LuaCommon/lualib/mw.hash.lua
Marius Hoch 0f4db74148 Add mw.hash to Scribunto
Provides a simple wrapper for PHP's hash() and
hash_algos() functions.

I will add docs to the Lua reference manual once
this is merged.

Bug: T142585
Change-Id: I6697463974a175e99f9b77428a1085247165ebc9
2016-08-18 04:39:04 +02:00

31 lines
550 B
Lua

local hash = {}
local php
local util = require 'libraryUtil'
local checkType = util.checkType
function hash.listAlgorithms()
return php.listAlgorithms()
end
function hash.hashValue( algo, value )
checkType( 'hashValue', 1, algo, 'string' )
checkType( 'hashValue', 2, value, 'string' )
return php.hashValue( algo, value )
end
function hash.setupInterface()
-- Boilerplate
php = mw_interface
mw_interface = nil
-- Register this library in the "mw" global
mw = mw or {}
mw.hash = hash
package.loaded['mw.hash'] = hash
end
return hash