Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Undefined array key 1 in /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php on line 339

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80
Модуль:Hash — Энциклопедия Акриции

Модуль:Hash

Материал из Энциклопедия Акриции
Версия от 09:34, 8 января 2024; Unifiedakricia (обсуждение | вклад) (Новая страница: «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">Не указана строка для...»)
(разн.) ← Предыдущая версия | Текущая версия (разн.) | Следующая версия → (разн.)

Для документации этого модуля может быть создана страница Модуль:Hash/doc

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
		-- Алгоритм выбран из соображений быстродействия (см. [[:en:Fowler–Noll–Vo hash function]]),
		-- 64-битная функция используется для уменьшения вероятности коллизий до пренебрежимо малой
		-- величины. Возможно, есть лучшая опция — проверяйте.
		algorithm = 'fnv164'
	end
	
	return mw.hash.hashValue(algorithm, args[1])
end

return p

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80

Warning: Cannot modify header information - headers already sent by (output started at /lilacspace/sites/ru.wiki.akrt.me/extensions/Scribunto/includes/Engines/LuaStandalone/LuaStandaloneInterpreter.php:339) in /lilacspace/sites/ru.wiki.akrt.me/includes/Request/WebResponse.php on line 80