Module:Hash
Навигацияға өту
Іздеуге өту
local getArgs = require('Module:Arguments').getArgs
local p = {}
local function inTable(table, value)
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
function p.list(frame)
return table.concat(mw.hash.listAlgorithms(), '; ')
end
function p.main(frame)
local args = getArgs(frame, { frameOnly = true })
local algorithm
if not args[1] then
return '<span class="error">Хештеу үшін жол көрсетілмеген.</span>'
end
if args[2] then
if not inTable(mw.hash.listAlgorithms(), args[2]) then
return '<span class="error">' .. args[2] .. ' хештеу алгоритмі қолданбайды немесе сіз есімді дұрыс көрсетпедеңіз. Қолжетімді алгоритимнен қажетті тізімдер алу үшін <kbd>mw.hash.listAlgorithms()</kbd> функциясын қолданыңыз.</span>'
end
algorithm = args[2]
else
algorithm = 'fnv164'
end
return mw.hash.hashValue(algorithm, args[1])
end
return p